[Twisted-Python] connectTCP() passing a ClientFactory: how to get the local port of the created client socket?

Alessio Pace alessio.pace at gmail.com
Tue Jan 13 10:06:21 EST 2009

On Tue, Jan 13, 2009 at 3:42 PM, Jean-Paul Calderone <exarkun at divmod.com>wrote:

> On Tue, 13 Jan 2009 15:34:19 +0100, Alessio Pace <alessio.pace at gmail.com>
> wrote:
>> Hi,
>> I'm having some difficulties in trying to figure out how to get a
>> reference
>> to the connector or anyway the local port to which a client socket is
>> bound
>> in a reactor.connectTCP() call, where the bindAddress is not passed as
>> parameter, thus letting the OS pick an available port.
>> In fact in the ClientFactory has a buildProtocol(self, addr) method, but
>> 'addr' is the address of the remote endpoint of the client socket
>> created..
>> Thanks in advance for any suggestion.
> The protocol gets connected to a transport with a `getHost´ method which
> returns an IPv4Address object with `host´ and `port´ attributes.  You
> can't get this information from the connector, since the connector exists
> for longer than a single connection.

Thanks a lot, this perfectly replies to my question. I should have looked a
bit more in the sources :-)

Alessio Pace.

> Jean-Paul
> _______________________________________________
> 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/20090113/3c584228/attachment.htm 

More information about the Twisted-Python mailing list