Getting a free TCP port & blocking it

Tim Roberts timr at
Sat Mar 1 08:11:39 CET 2008

theneb <onetwofour at> wrote:
>Hi all,
>I'm attempting to block a TCP port from any other application from
>using it until I free it from python, this is so that:
>1). Generate a random free user-space port
>2). Generate the script for the external program with the port
>3). Free the port before external program execution.

What's the point?  Why can't the actual user of the port create the port,
and then notify the other side of the port number?

And why don't you just specify a port number of 0 and let the system assign
you a free port number?
Tim Roberts, timr at
Providenza & Boekelheide, Inc.

More information about the Python-list mailing list