check for unused ports and then grab one
Josh Close
narshe at gmail.com
Mon Sep 13 18:12:18 EDT 2004
I believe you should be able to just bind to port 0. Then it will pick
up an available one and you won't have to worry about it.
-Josh
On Mon, 13 Sep 2004 22:08:10 GMT, Cameron Laird <claird at lairds.us> 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.
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list