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

Alessio Pace alessio.pace at gmail.com
Fri Jan 9 09:13:10 EST 2009


On Fri, Jan 9, 2009 at 3:01 PM, Alvin Delagon <adelagon at gmail.com> wrote:

> You shouldn't bind your client on a port where your server is listening to.


I'm following what is written in "Peer-to-Peer Communication Across Network
Address Translators" in order to implement TCP hole punching, and they
suggested to do so..

Regards,
--
Alessio Pace.



>
>
> ---
> Alvin
>
> On Fri, Jan 9, 2009 at 9:23 PM, Alessio Pace <alessio.pace at gmail.com>wrote:
>
>> 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.
>>
>>
>> _______________________________________________
>> Twisted-Python mailing list
>> Twisted-Python at twistedmatrix.com
>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>>
>>
>
>
> --
> http://www.alvinatorsplayground.blogspot.com/
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20090109/6d12fd63/attachment.htm 


More information about the Twisted-Python mailing list