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

相关文章:

  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
  • 2021-06-04
猜你喜欢
  • 2022-12-23
  • 2021-11-04
  • 2021-10-16
  • 2021-06-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案