check for unused ports and then grab one

Michael Sparks michaels at rd.bbc.co.uk
Tue Sep 14 08:15:25 EDT 2004


Peter Hansen wrote:
...
> I'm curious what you are trying to do though.  Normally a server
> has to listen on a predefined port or the clients won't be able
> to connect, and a client doesn't need to specify which port it
> will bind to as the OS will pick a free one automatically.  I've
> never had to do what you are trying to do, thus my curiosity...

One place where it is useful in an non-passive FTP client. IE It needs
to allow the server to connect back to an port on the client for
transfer of data. The client tells the server the IP/port number, and
since the client doesn't normally have one of these open it's often
useful just to let the local TCP stack allocate the port number, find
out what it is and tell the server.

Regards,


Michael.
-- 
Michael.Sparks at rd.bbc.co.uk    
British Broadcasting Corporation, Research and Development
Kingswood Warren, Surrey KT20 6NP

This message (and any attachments) may contain personal views
which are not the views of the BBC unless specifically stated.





More information about the Python-list mailing list