echoserver.py
来自「大型多人在线游戏开发,该书光盘上附带的源码」· Python 代码 · 共 11 行
PY
11 行
from twisted.internet.protocol import Protocol, Factoryclass Echo(Protocol): # Class designed to manage a connection. def dataReceived(self, data): # Method called when data is received. self.transport.write(data) # When we receive data, write it back out.class EchoFactory(Factory): def buildProtocol(self, address): return Echo() # Build Protocols on incoming connectionsfrom twisted.internet import reactorreactor.listenTCP(1234, EchoFactory()) # Bind TCP Port 1234 to an EchoFactoryreactor.run() # run the main loop until the user interrupts it
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?