FTP Data Connections

FTP uses two socket connections, a control connection and a data connection. We use the control connection to send commands and receive responses, but we don’t use this connection for exchanging large amounts of data. By using a separate data connection, we can continue to manage the session on the control socket, while exchanging the data on the data connection.

The server must initiate the data connection. If the client initiates the data connection, the server has no way of knowing whether the connection was for a control or data connection. Because the server initiates the data connection, the server knows that any incoming connection requests are for control connections. The client knows that any incoming connection requests are for data connections.

The data connection is valid only during the data transfer between the FTP client and server. The server initiates the data connection and notifies the client to begin exchanging data. When the data exchange is complete, the connection is closed.

The Data Socket

USER and PASS commands send client data to the server. The server’s responses contain reply codes and text messages for an end user that will likely never see them. Because commands and responses are textual and small, we can safely send them over the control connections.

Other operations might potentially exchange large amounts of data, which might flow either from client to server or server to client, and which does not fit well in the command/response ...

Get Palm OS Network Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.