The PASV Command
A PASV request asks the server to accept a data connection on a new TCP port selected by the server. PASV parameters are prohibited.
The server normally accepts PASV with code 227. Its response is a single line showing the IP address of the server and the TCP port number where the server is accepting connections.
Normally the client will connect to this TCP port, from the same IP address that the client is using for the FTP connection, and then send a RETR request (see below). However, the client may send some other requests first, such as REST. The server must continue to read and respond to requests while it accepts connections. Most operating systems handle this automatically.
If the client sends another PASV request, the server normally accepts the new request with a new TCP port. It stops listening for connections on the old port, and drops any connections already made.
All servers that support file transfers are required to support PASV. Many clients rely on PASV , and will give up on a file transfer if PASV is rejected.
The PORT Command
A PORT request asks the server to use a different mechanism of creating a data connection: the server makes a TCP connection to the client.
The PORT request has a parameter in the form
h1,h2,h3,h4,p1,p2
meaning that the client is listening for connections on TCP port p1*256+p2 at IP address h1.h2.h3.h4.
The server normally accepts PORT with code 200. If the server was listening for a connection, it stops, and drops any connections already made.
The server does not connect to the client's port immediately. After the client sends RETR and after the server sends its initial mark, the server attempts to connect. It rejects the RETR request with code 425 if the connection attempt fails; otherwise it proceeds normally.
In theory, the client can send RETR without a preceding PORT or PASV . The server is then supposed to connect to port 20 at the client's IP address.In practice, however, servers refuse to do this.
For security reasons, clients should never use PORT. However, some clients still rely on PORT, and will give up on a file transfer if PORT is rejected. My current recommendation is that servers continue to support PORT.