[Twisted-Python] Re: How to get an unused port

Thomas Hervé therve at free.fr
Wed Feb 27 07:59:04 EST 2008

Quoting Gabriel Rossetti <mailing_lists at evotex.ch>:

>>>> reactor.listenTCP(0, Factory()).getHost().port
> 59768

That's the good thing to use.

> or
>>>> reactor.listenTCP(0, Factory())._realPortNumber
> 47315
> work :-)

Indeed, but please don't do that. The underscore prefix indicated a  
private member, so this is the kind of thing that can disappear or  
change without warnings. In this case, the previous pattern should do  
the job.


More information about the Twisted-Python mailing list