"Fredrik Lundh" <fredrik at pythonware.com> writes: > Grant Edwards wrote: > > IIRC, you just call bind() with a port number of zero, and then > > use some method-or-other on the bound socket to find out what > > port it's bound to. > > >>> s = socket.socket() > >>> s.bind(("", 0)) > >>> s.getsockaddr() > ("0.0.0.0", 4711) Nice. Thanks.