check for unused ports and then grab one

Barry Margolin barmar at alum.mit.edu
Tue Sep 14 03:36:45 CEST 2004


In article <9vhh12-suo.ln1 at lairds.us>, claird at lairds.us (Cameron Laird) 
wrote:

> In article <mailman.3268.1095108346.5135.python-list at python.org>,
> Erik Heneryd  <erik at heneryd.com> wrote:
> >Brad Tilley wrote:
> >> Instead of me arbitrarily assigning a high port number to a variable, is 
> >> it possible to check for ports that are unused and then randomly assign 
> >> one of them to a variable?
> >
> >No.  Trial and error until you find one.
> 			.
> 			.
> 			.
> Incorrect, if I understand you both; *UNIX Network Programming*
> has said for years that
>   The process can let the system automatically assign 
>   a port.  For both the Internet domain and the XNS
>   domain, specifying a port number of 0 before calling
>   bind() requests the system to do this.
> While I've never tracked down an RFC that specifies this, it surely
> exists.

There's no reason for it to be in an RFC, because it's an API issue, not 
a protocol issue.

-- 
Barry Margolin, barmar at alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***



More information about the Python-list mailing list