"""The most basic chat protocol possible.run me with twistd -y chatserver.py, and then connect with multipletelnet clients to port 1025"""from twisted.protocols.basic import LineReceiverclass MyChat(basic.LineReceiver): def __init__(self): self.quote = 'An apple a day keeps the doctor away' def connectionMade(self): print "Got new client!" self.factory.clients.append(self) def connectionLost(self, reason): print "Lost a client!" self.factory.clients.remove(self) def lineReceived(self, line): print "received", repr(line) for c in self.factory.clients: c.message("respuesta server: " + line) def message(self, message): self.sendLine(message + '\n')from twisted.internet import protocol, reactorfrom twisted.application import service, internetfactory = protocol.ServerFactory()factory.protocol = MyChatfactory.clients = []reactor.listenTCP(8007, factory)reactor.run()#application = service.Application("chatserver")#internet.TCPServer(1025, factory).setServiceParent(application)