twisted-从客户端接受连接
from twisted.internet import reactor, protocolfrom twisted.protocols import basicclass EchoProtocol(basic.LineReceiver): def lineReceived(self, line): if line == 'quit': self.sendLine("Goodbye.") self.transport.loseConnection( ) else: self.sendLine("You said: " + line)class EchoServerFactory(protocol.ServerFactory): protocol = EchoProtocolif __name__ == "__main__": port = 5001 reactor.listenTCP(port, EchoServerFactory( )) reactor.run( )
?