Sockets - how to nominate local port number?
Peter Hansen
peter at engcorp.com
Sat Jan 26 17:43:15 EST 2002
djmitchell wrote:
>
> For a particular sockets application I'm working on, I need to be able to
> specify both the port number on the remote machine, *and* the port number
> on the local machine. In other words, the function/method call to
> establish the connection needs to look something like this:
> ...
> socket = connect(remote_host, remote_port, local_port)
> ...
>
> Any suggestions how to go about this? For "normal" apps, you don't usually
> care about the local port number, but the security requirements of this
> particular application mean that I have to specify it.
I believe bind()ing a socket to a port works fine even for a client
socket. Just don't execute listen()...
More information about the Python-list
mailing list