[Twisted-Python] How to listen on and connect from same TCP port with Twisted?

Alessio Pace alessio.pace at gmail.com
Fri Jan 9 08:23:12 EST 2009


Hi,

I would lilke tro listen on a given TCP port and initiate multiple TCP
client connections from the same port, but I'm encountering the classical:

  <class 'twisted.internet.error.ConnectBindError'>: Couldn't bind: 98:
Address already in use

My code is:

######################################

    factory = Factory()
    # an almost empy subclass of Protocol
    factory.protocol = TCPServer

    reactor.listenTCP(12345, factory)

    # ClientFactory subclass which simply instantiate a TCPClient Protocol
    client_factory = TCPClientFactory()

    # last tuple is the bindAdress parameter
    reactor.connectTCP(target_addr, 12345, client_factory, 30, (source_addr,
12345))

#######################################

I've tried to look on the Internet and in the source code but I've not found
a proper solution.

Thanks in advance for any suggestion.
Alessio Pace.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20090109/be1f9de2/attachment.htm 


More information about the Twisted-Python mailing list