2
votes
  1. After the control connection to port 21 is created, the FTP server sends the 220 (service ready) response on the control connection.

  2. The client sends the USER command.

  3. The server responds with 331 (user name is OK, a password is required).

  4. The client sends the PASS command.

  5. The server responds with 230 (user login is OK).

  6. The client issues a passive open on an ephemeral port for the data connection and sends the PORT command (over the control connection) to give this port number to the server.

  7. The server does not open the connection at this time, but prepares itself for issuing an active open on the data connection between port 20 (server side) and the ephemeral port received from the client. It sends the response 150 (data connection will open shortly).

  8. The client sends the TYPE command.

  9. The server responds with the response 200 (command OK).

  10. The client sends the STRU command.

  11. The server responds with 200 (command OK).

  12. The client sends the STOR command.

  13. The server opens the data connection and sends the response 250.

  14. The client sends the file on the data connection. After the entire file is sent, the data connection is closed. Closing the data connection means end-of-file.

  15. The server sends the response 226 on the control connection.

  16. The client sends the QUIT command or uses other commands to open another data connection for transferring another file. In our example, the QUIT command is sent.

  17. The server responds with 221 (service closing) and it closes the control connection.


in point 14.

  1. The client sends the file on the data connection. After the entire file is sent, the data connection is closed. Closing the data connection means end-of-file.

does the client close the data connection?

if so how does it do that. just disconnects! or sends a disconnect command using the control connection?

1

1 Answers

5
votes

The default transmission mode is STREAM. On a stream file upload, the data connection is just closed. No command is sent. Just close the connection.

If you were to send a command, whatever you sent would be appended to the file.

The stream mode is unreliable because there is no EOF marker. Also, you must reopen the connection for each additional file. It is better to use BLOCKED or COMPRESSED for reliability and will improve performance when sending multiple small files, though there is a small overhead for the protocol.

Use the MODE command to set the transmission mode.