how to get any available port
jepler at unpythonic.net
jepler at unpythonic.net
Tue Oct 4 17:25:30 EDT 2005
On Tue, Oct 04, 2005 at 05:19:37PM -0400, Mohammed Smadi wrote:
> what else would you do? I am using examples from the web and they all
> bind to a port at the localhost before connecting to the remote host.
[...]
the web must be stupider than I thought.
Here's how Python's own ftplib connects to an ftp server (dedented for clarity):
try:
self.sock = socket.socket(af, socktype, proto)
self.sock.connect(sa)
except socket.error, msg:
...
there's no need to call bind() before connect.
Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20051004/36f59d10/attachment.sig>
More information about the Python-list
mailing list