Apparently, calling bind() with a zero "port" will choose some available port number, as demonstrated by this program:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("", 0))
print s.getsockname()
Here's how it behaved over several runs:
$ python soc.py
('0.0.0.0', 34205)
$ python soc.py
('0.0.0.0', 34206)
$ python soc.py
('0.0.0.0', 34207)
I don't know for sure whether this is standard behavior for sockets, or whether
it's a special behavior of linux.
Jeff
pgpdXrF07MIY9.pgp
Description: PGP signature
-- http://mail.python.org/mailman/listinfo/python-list
