I am learning the Twisted framework for a project I am working on by using the Twisted Documentation Finger tutorial (http://twistedmatrix.com/documents/current/core/howto/tutorial/intro.html) and I'm having trouble getting my program to work.
Here's the code for the server, it should return "No Such User" when I telnet localhost 12345
, but it just stays there, nothing happening.
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()
I have run the server via python twisted-finger.py
and sudo python twisted-finger.py
, but neither worked.
Does anyone see why this doesn't return the message it is supposed to?
You have to send a finger request to the server before it responds.
According to the finger rfc:
Try typing a word into telnet and hitting enter.