我正在使用 Twisted Documentation Finger 教程 ( http://twistedmatrix.com/documents/current/core/howto/tutorial/intro.html ) 为我正在从事的项目学习 Twisted 框架,但我无法获得我的程序工作。
这是服务器的代码,它应该在我返回“没有这样的用户”时telnet localhost 12345
,但它只是停留在那里,没有发生任何事情。
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
and运行了服务器sudo python twisted-finger.py
,但都没有工作。
有谁知道为什么这不会返回它应该返回的消息?