FTP (file transfer protocol) is the file transfer protocol. Copying a file from a remote FTP server to a local computer through an FTP client is called a download. copying a file from a local computer to a remote FTP server is called an upload, uploading and downloading are the two most common FTP functions. FTP uses the TCP protocol of the transport layer for transmission. Therefore, the connection between the client and the server is reliable and connection-oriented, providing reliable guarantee for data transmission. FTP has the following goals:
- Improve file sharing
- Provides non-direct Remote Computer Control
- Avoid changes caused by differences in file storage systems between hosts
- Providing reliability and efficiency for data transmission
Shows the FTP protocol model.
FTP uses the TCP Service, which requires two connections. One is data connection for data transmission. Generally, port 21 is used, while the other is control connection for transmitting control information (commands and responses). Generally, Port 20 is used. The control connection only needs to transmit control information, such as a command line or a response code line. The data type to be transferred by the data connection is complex, such as text files, graphic files, and applications.
Shows the interaction elements used in the FTP protocol model, including user interfaces, userpi, uptp, SPI, and sdtp.
There are two FTP transmission modes: text transmission mode and binary data transmission mode. The text mode is also called the ASCII mode, and the binary mode is also called the binary mode.
FTP services are classified into two types: Common FTP and anonymous FTP services.
Common FTP commands include:
1) access command
User: Specifies the user name.
Pass: Specifies the password corresponding to the user name
Abor: The Data Connection Program is interrupted abnormally.
Quit: log out from the system
Rein: reinitialization
2) file management commands
CWD: change the working directory on the server to the specified directory.
Cdup: change the working directory on the server to the parent directory.
Dele: requests to delete files on the server.
List: List subdirectories or files
MKD: request to create a new directory on the server
PWD: displays the current working directory
RMD: deletes a specified directory from the server.
3) data formatting command
Type: defines the file type. There are four types of parameters included: A, E, I, and l correspond to the ASCII, ebcdic, imagb, and local types respectively.
Stru: defines the data organization
Mode: defines the transmission mode.
4) Port definition command
PASV: select a port for the server. The client uses this port to actively open the port.
Port: select a port from the client. The server uses this port to create an active port.
5) file transfer command
RETR: reads files, which are transmitted from the server to the client.
Stor: stores files, which are transmitted from the client to the server.
Stat: returns the File status.
Alloo: allocate storage space for files on the server
6) Miscellaneous commands
Help: Ask the server information
Noop: Check whether the server is working
Site: commands for specific locations
Syst: the operating system used by the server.
After the client sends the FTP command, the server returns the response code. The response code is encoded in three digits:
The first number defines the command status.
1 indicates that the server has correctly received the information and has not yet processed it.
2 indicates that the server has correctly processed the information.
3 indicates that the server receives the correct information and is processing it.
4 indicates that the information is temporarily incorrect.
5 indicates that the information is permanently incorrect.
The second number is the type of response.
0 indicates the syntax.
1 indicates the system status and information.
2 indicates the connection status.
3 indicates information related to user authentication.
4 indicates that it is not specified.
5 indicates information related to the file system.
The third number provides additional information.
========================================================== ========================================================== ============================
Author: Ouyang Peng: Welcome to repost. sharing with others is the source of progress!
Reprinted Please retain the original address: http://blog.csdn.net/ouyang_peng/article/details/9633781
========================================================== ========================================================== ==============================