[Twisted-Python] multiple connectTCP bindaddress problem

Tommi Virtanen tv at twistedmatrix.com
Fri Nov 5 01:01:55 EST 2004


Chris Laws wrote:

>My understanding is that this should create a valid TCP connection to each different server
>IP:port address, all originating from the same client IP:Port. Maybe there is a fundamental flaw
>in my understanding of TCP but I think I can have multiple remote addresses connected to the
>same local IP:port address.
>  
>
This is a generic BSD socket API question that has nothing to do with 
Twisted or Python.

Connections are identified by (srcIP, srcPort, dstIP, dstPort), yes. The 
protocol
allows what you are asking. But of course even if the protocol allows 
something,
not all implementations are not required to allow you to do it. In this 
case, the
behaviour is selectable, with the default being do not allow it.

>Anyway this seems to be where my problem exists because when I define the same 'bindaddress'
>IP:Port tuple to each connectTCP call, I only seem to be able to connect to one remote server
>from the client application.
>  
>
Try "man 2 socket",

       SO_REUSEADDR
              Indicates that the rules used in validating addresses supplied in a bind(2) call should allow reuse of  local
              addresses.  For  PF_INET  sockets this means that a socket may bind, except when there is an active listening
              socket bound to the address.  When the listening socket is bound to INADDR_ANY with a specific port  then  it
              is not possible to bind to this port for any local address.






More information about the Twisted-Python mailing list