Exemplo n.º 1
0
 def __init__(self):
     TCPApplication.__init__(self)
Exemplo n.º 2
0
        """Return either or not the port sent in parameter is free"""
        return self.tcp.is_port_free(p)
    
    def is_udp_port_free(self, p):
        """Return either or not the port sent in parameter is free"""
        return self.udp.is_port_free(p)

    def set_custom_session(self, sess):
        """ Method that allow to change the kind of session created when registering tcp application """
        self._session = sess


if __name__ == "__main__":
    stack = PyStack()
    
    conn = TCPApplication()
    stack.register_tcp_application(conn)
    stack.run(False)
    
    '''conn.bind(8888)
    conn.listen(2)
    
    s = conn.accept()
    '''
    print(conn.connect("perdu.com", 80))
    
    conn.send_packet("GET / HTTP/1.0\r\nUser-Agent: Wget/1.12 (linux-gnu)\r\nAccept: */*\r\nHost: perdu.com\r\nConnection: Keep-Alive\r\n\r\n")
    
    time.sleep(10)
    
    conn.close()
Exemplo n.º 3
0
 def __init__(self):
     TCPApplication.__init__(self)