check for unused ports and then grab one

Cameron Laird claird at lairds.us
Mon Sep 13 18:08:10 EDT 2004


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.



More information about the Python-list mailing list