Ejemplo n.º 1
0
 def _client_and_server(self, port):
     server = TCPServer(LOCAL_IP, port)
     client = TCPClient()
     try:
         yield client, server
     finally:
         server.close()
         client.close()
Ejemplo n.º 2
0
 def _client_and_server(self, port):
     server = TCPServer(LOCAL_IP, port)
     client = TCPClient()
     try:
         yield client, server
     finally:
         server.close()
         client.close()
Ejemplo n.º 3
0
 def _tcp_server_and_client(self, server_port, client_port=None, timeout=None):
     server = TCPServer(LOCAL_IP, server_port, timeout=timeout)
     client = TCPClient(timeout=timeout)
     if client_port:
         client.set_own_ip_and_port(LOCAL_IP, client_port)
     client.connect_to(LOCAL_IP, server_port)
     self.sockets.append(server)
     self.sockets.append(client)
     return server, client
Ejemplo n.º 4
0
 def test_tcp_server_with_named_connection(self):
     server = TCPServer(LOCAL_IP, 1337)
     TCPClient().connect_to(LOCAL_IP, 1337)
     server.accept_connection(alias=CONNECTION_ALIAS + "1")
     self.assertTrue(server._connections.get(CONNECTION_ALIAS + "1"))
Ejemplo n.º 5
0
 def test_tcp_server_with_no_connections(self):
     server = TCPServer(LOCAL_IP, 1338)
     client = TCPClient()
     client.connect_to(LOCAL_IP, 1338)
     client.send('foofaa'.encode())
     self.assertRaises(AssertionError, server.receive)
Ejemplo n.º 6
0
 def test_tcp_server_with_named_connection(self):
     server = TCPServer(LOCAL_IP, 1337)
     TCPClient().connect_to(LOCAL_IP, 1337)
     server.accept_connection(alias=CONNECTION_ALIAS + "1")
     self.assertTrue(server._connections.get(CONNECTION_ALIAS + "1"))
Ejemplo n.º 7
0
 def _tcp_server(self, server_port, timeout=20):
     server = TCPServer(LOCAL_IP, server_port, timeout=timeout)
     self.sockets.append(server)
     return server