首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

twisted-从客户端接受联接

2012-10-14 
twisted-从客户端接受连接from twisted.internet import reactor, protocolfrom twisted.protocols import

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

?

热点排行