Data connections may be set up in
two different ways, active and passive. Note that active
and passive refer to the operation of the FTP server, not the client.
Passive
mode
In
passive mode, the client sends a PASV command to the server. This tells
the server to
listen for a connection attempt from the client, hence the server is
passively waiting. The
server replies to PASV with the host and port address that the server
is listening on. The client
deciphers this reply and when a data connection is required, attempts
to initiate the connection
to the server at this address.
Active
mode
In
active mode, the server actively connects to the client. To set up
active mode, the client
sends a PORT command to the server, specify the address and port number
the client is
listening on. When a data connection is required, the server initiates
a connection to the client
at this address.
Generally
the server is responsible for closing data connections.