class ChatServer(Protocol):
def connectionMade(self):
print("A Client Has Connected")
factory = Factory()
reactor.listenTCP(80,factory)
You haven't made any association between factory
and ChatServer
in this code. Try inserting this line:
factory.protocol = ChatServer
In an upcoming (not yet released) version of Twisted, Factory
is getting a new class method to make this set-up even easier. Using that version, this example would be even shorter:
class ChatServer(Protocol):
def connectionMade(self):
print("A Client Has Connected")
reactor.listenTCP(80, Factory.forProtocol(ChatServer))