读书人

twisted-从客户端接受联接

发布时间: 2012-10-14 14:55:07 作者: rapoo

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( )

?

读书人网 >编程

热点推荐