def connected_server_and_client(case, server_factory, client_factory):
 def connect_client(listening_port):
  return TCP4ClientEndpoint(reactor, '127.0.0.1', listening_port.getHost().port).connect(client_factory)
 return listen(case, TCP4ServerEndpoint(reactor, 0), server_factory).addCallback(connect_client)

def connected_server_and_client ( case , server_factory , client_factory ) : def connect_client ( listening_port ) : return TCP4ClientEndpoint ( reactor , '127.0.0.1' , listening_port . getHost ( ) . port ) . connect ( client_factory ) return listen ( case , TCP4ServerEndpoint ( reactor , 0 ) , server_factory ) . addCallback ( connect_client )
create a server and client connected to that server .