【发布时间】:2013-12-16 18:32:41
【问题描述】:
我正在使用 Twisted Documentation Finger 教程 (http://twistedmatrix.com/documents/current/core/howto/tutorial/intro.html) 为我正在从事的项目学习 Twisted 框架,但我无法让我的程序正常工作。
这是服务器的代码,当我telnet localhost 12345 时它应该返回“No such User”,但它只是停留在那里,没有任何反应。
from twisted.internet import protocol, reactor
from twisted.protocols import basic
class FingerProtocol(basic.LineReceiver):
def lineReceived(self, user):
self.transport.write("No such user\r\n")
self.transport.loseConnection()
class FingerFactory(protocol.ServerFactory):
protocol = FingerProtocol
reactor.listenTCP(12345, FingerFactory())
reactor.run()
我已经通过python twisted-finger.py 和sudo python twisted-finger.py 运行了服务器,但都没有成功。
有谁明白为什么这没有返回它应该返回的消息?
【问题讨论】:
标签: python-2.7 twisted twisted.internet