-
After the control connection to port 21 is created, the FTP
server sends the 220 (service
ready) response on the control connection. -
The client sends the USER command.
-
The server responds with 331 (user name is OK, a password
is required). -
The client sends the PASS command.
-
The server responds with 230 (user login is OK).
-
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. -
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). -
The client sends the TYPE command.
-
The server responds with the response 200 (command OK).
-
The client sends the STRU command.
-
The server responds with 200 (command OK).
-
The client sends the STOR command.
-
The server opens the data connection and sends the
response 250. -
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. -
The server sends the response 226 on the control
connection. -
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. -
The server responds with 221 (service closing) and it closes
the control connection.
in point 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.
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?
Best Answer
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.