twisted: echo server

from twisted.internet import protocol, reactor

class Echo(protocol.Protocol):
    def dataReceived(self, data):
        self.transport.write(data)

class EchoFactory(protocol.Factory):
    def buildProtocol(self, addr):
        return Echo()

reactor.listenTCP(1234, EchoFactory())
reactor.run()

 

run server:

python testTwisted.py

 

run client:

telnet localhost 1234

posted on 2012-01-13 00:51 cutepig 阅读(15) 评论(0) 编辑 收藏

导航

<2012年1月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234

公告

昵称:cutepig
园龄:4年8个月
粉丝:11
关注:0

搜索

 
 

常用链接

随笔分类(58)

随笔档案(536)

文章档案(1)

我的链接

积分与排名

  • 积分 - 193028
  • 排名 - 443

最新评论

阅读排行榜