from twisted.internet import protocol class EchoFactory(protocol.ServerFactory): def buildProtocol(self, addr): p = Echo() p.factory = self return p