[Twisted-Python] Binding echo server to a particular ip address

Morrow, Paul Paul.Morrow at loyaltyworks.com
Wed May 14 13:35:56 EDT 2003


The following is your simpleserv.py echo server example.  On a multihost
(multiple ip addresses) server, how would I have it listen on a
particular ip address?
 
Thanks.
 
 
 
from twisted.internet import reactor, protocol


class Echo(protocol.Protocol):
    """This is just about the simplest possible protocol"""
    
    def dataReceived(self, data):
        "As soon as any data is received, write it back."
        self.transport.write(data)


def main():
    """This runs the protocol on port 8000"""
    factory = protocol.ServerFactory()
    factory.protocol = Echo
    reactor.listenTCP(8000,factory)
    reactor.run()

# this only runs if the module was *not* imported
if __name__ == '__main__':
    main()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20030514/4a59044b/attachment.htm 


More information about the Twisted-Python mailing list