Outbound port on sockets

Diez B. Roggisch deets at nospam.web.de
Thu Sep 14 08:47:15 EDT 2006


bmearns schrieb:
> Is it possible to specify which port to use as the outbound port on a
> connection? I have the IP address and port number for the computer I'm
> trying to connect to (not listening for), but it's expecting my
> connection on a certain port.
> 
> Specifically, I'm trying to write an FTP host, and I'm trying to
> implement the PORT command. From everything I've read, the client
> supplies the IP address and port number for where I'm supposed to
> connect to send it data (like a LISTing), and it's expecting me to
> connect over port 20. If anyone is familiar with FTP and can tell me
> whether this is true or not, whether I really need to go out on port
> 20, I'd appreciate it, as well.

AFAIK you neither can't do that nor need it. The PORT commands purpose 
is to tell where the server can connect to - but the client makes no 
assumptions over the source port of that connection. Let alone NAT and 
other things could come into your way.

If firewalls are a problem, use PASV.

Diez



More information about the Python-list mailing list