FTP Response Code

Source: Internet
Author: User
Tags ftp commands ftp connection ftp file response code ftp client file transfer protocol ftp file transfer ftp protocol

FTP protocol

1. File Transfer

 

The file transmission service is an essential service for the Network Interconnection Environment. Currently, the most important transmission mode for file transmission in the network is the FTP protocol.

 

FTP, full name: File Transfer Protocol, Chinese name is file transfer protocol, it can transmit electronic documents, pictures, sound, film and television,ProgramAnd programs. If you need to send files from your computer to another computer, you can use FTP upload or put operations, in more cases, you can use ftp to download or get files from the FTP server.

 

2. How FTP works

Two types of connections are required for a complete FTP file transfer. One is a file transfer command called a control connection, and the other is a real file transfer called a data connection.

1) control connection

When the client wants to establish an upload/download data transmission with the FTP server, it first initiates a connection establishment request to the TCP port 21 of the server. The FTP Server accepts requests from the client, after the connection is established, the connection is called an FTP control connection.

2) Data Connection

After the FTP control connection is established, you can start transferring files. The file transfer connection is called an FTP data connection. FTP data connection is the process of FTP data transmission. It has two transmission modes: Active Transmission Mode (port) and passive transmission mode (PASV ). In active transmission mode, the FTP server uses Port 20 to connect to the temporary port of the client and transmit data. The client is only in the receiving status. In passive transmission mode, the FTP Server opens a transient port and waits for the client to connect to it and transmit data. The server does not participate in active data transmission, but passively accepts the data.

Two FTP working modes: active FTP and Passive FTP)

In active mode, the FTP client starts a random connection from Port n greater than 1024 to port 21 of the server, and then opens port n + 1 for listening, and issue the port n + 1 command to the server. After receiving the command, the server uses its local FTP data port (usually 20) to connect to the specified port n + 1 of the client for data transmission.

In passive mode, the FTP client randomly opens a port n greater than 1024 to initiate a connection to port 21 of the server, and opens port n + 1. Then, send the PASV command to the server to notify the server that it is in passive mode. After receiving the command, the server opens a port P greater than 1024 for listening, and then uses the port p command to notify the client that its own data port is P. After receiving the command, the client connects to port P of the server through port n + 1 and transmits data between the two ports.

In general, active FTP refers to the data port on which the server actively connects to the client, and Passive FTP refers to the data port on which the server passively waits for the client to connect to itself.

In passive mode, FTP is usually used when FTP customers in the firewall access the external FTP server, because in this case, the firewall is usually configured to not allow external access to the host after the firewall, only connection requests initiated by hosts after the firewall are allowed to pass. Therefore, in this case, FTP transmission in active mode cannot be used, while FTP in passive mode can work well.

(

 

?

 

 

The difference is:

The active mode is the client bind a port, and the server writes the data to the port opened by the client from the server's 20 port.

In passive mode, the client requires the server to open a port, and then the client connects the port to fetch the data.

 

A concise point is:

In active mode, the server writes data to the client.

In passive mode, the client goes back to the server to fetch the data.

 

)

 

 

3. FTP command

Common FTP commands are shown in table 1.

 

 

Command

 

Description

 

User

 

Provide user name for User Authentication

 

Pass

 

Provide password for User Authentication

 

PWD

 

Output the current working directory of the FTP server

 

Type

 

Set the file type for Transmission

 

Syst

 

Obtain the FTP server operating system

 

List

 

Obtains the list of files in the current directory on the FTP server.

 

Port

 

Specify to use active mode for data transmission

 

PASV

 

Data transmission in passive mode

 

Help

 

Obtain help files from the FTP server

 

Stor

 

Upload the specified file from the client to the FTP server

 

RETR

 

Download the specified file from the FTP server to the client

 

Dele

 

Delete the specified file on the FTP server

 

MKD

 

Create a directory on the FTP server

 

 

RMD

 

 

Delete the specified directory on the FTP server

 

 

Quit

 

 

Exit and close the FTP connection

 

 

(Table 1 FTP Common commands)

4. FTP Response

From the above analysis, we can know that the FTP server will respond to all the commands sent by the client,

FTP response code and its significance
110 restart to mark the response. In this case, the text is determined. It must be Mark yyyy = Mmmm, where yyyy is the user process data stream mark and mmmm is the server mark.
120 prepare the service within NNN minutes
125 the data connection is enabled and is ready for transfer
150 the file is in good state and data connection is enabled
200 command successful
202 command not implemented
211 system status or help response
212 directory status
213 File status
214 help information, which is only useful to human users
215 name system type
220 prepare services for new users
221 close the control connection and log out.
225 data connection opened, no transmission in progress
226 close the data connection. The requested file X is successful.
227 enter passive mode
230 User Logon
250 the requested file X is complete
257 create a "pathname"
331 the user name is correct and a password is required
332 account information required for Logon
350 the requested file X requires further commands
421 unable to provide services, close the control connection
425 data connection cannot be enabled
426 close the connection and stop transmission
450 the requested file X is not executed
451 abort request X: Local Error
452 failed requests: insufficient storage space
500 format error, command unrecognized
501 parameter syntax error
502 command not implemented
503 Command Order Error
504 the command function under this parameter is not implemented
530 not logged on
532 account information required to store files
550 x actions for unexecuted requests
551 request X for suspension: Unknown page type
552 the requested file X is aborted, and the storage allocation overflows.
553 failed request: invalid file name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.