In the Internet, file transfer service provides a mechanism for any two computers to transfer files to each other. It is one of the important ways for users to obtain rich Internet resources.In UNIX operating system, one of the most basic application layer services is file transfer service, which is supported by FTP.FTP is responsible for transferring files from one computer to another and ensuring the reliability of their transmission.Therefore, people call this kind of service FTP service.Usually, people also regard FTP as user executionWebsite productionThe application used by the File Transfer Protocol.
The Internet uses TCP/IP protocol as its basic protocol.So no matter how far apart the two computers connected to the Internet are geographically, they can transfer files to each other anytime and anywhere as long as they both support FTP.This can not only save the communication cost of real-time online, but also facilitate the reading and processing of transferred files.More importantly, a large number of publicly issued programs and files are stored on the host computers of many companies and universities on the Internet, which is a huge and valuable information resource on the Internet.With FTP services, users can easily access these information resources.At the same time, when FTP is used to transfer files, there is no need for complex conversion of files, so it has high efficiency.The combination of Internet and FTP makes every networked computer have a huge backup file library, which is unmatched by a single computer.
1. Introduction to File Transfer Protocol
File Transfer Protocol (FTP) is the TCP/IP application layer protocol.FTP works in the client server mode.The client makes requests and accepts services, and the server accepts requests and executes services.When FTP is used for file transmission, that is, start the FTP client program on the local computer, and use it to establish a connection with the remote computer system to activate the FTP service program on the remote computer system. Therefore, the local FTP program becomes a client, and the remote FTP program becomes a server. They communicate through TCP (establishing a connection, the default port number is 21).Every time a user requests a file to be transmitted, the server is responsible for finding the file requested by the user, and transmitting the file to the customer through the Internet using TCP.After receiving the file, the client program writes the file to the hard disk of the user's local computer system.Once the file transfer is completed, the client program and the server program will terminate the TCP connection for data transfer.
It is different from other client/server modelsA dual connection needs to be established between the FTP client and the server. One is a control connection, and the other is a data connection, as shown in Figure 4-7.The separation of control and data transmission can make FTP work more efficiently.The control connection is mainly used to transmit FTP control commands and server echo information.Data connection is mainly used for data transmission to complete the transmission of file contents.
With the control command, the client can make a request to the server, for example, to transfer a group of files.Every time a client makes a request, the server will establish a data connection with the client and carry out the actual file data transmission.Once the data transmission is completed, the data connections are revoked one after another, but the control connection still exists. The client can continue to send requests to transfer files until the client uses the Close command to revoke the control connection, and then uses the Quit command. At this time, the connection between the client and the server is completely terminated.
2 .Main functions of FTP
When the user computer and the remote computer establish an FTP connection, file transfer can be performed. The main functions of FTP are as follows:
(1) Transfer one or more files from the local computer to the remote computer (upload) or obtain one or more files from the remote computer (download).FTP essentially copies the file and then uploads it to a remote computer, or downloads it to a local computer, without affecting the source file.
(2) It can transfer files of various types, structures and formats. For example, users can choose to transfer text files (ASCII) or binary files (Binary).In addition, you can also select file format control and file transfer mode.The user can determine which file type and structure to select during file transmission according to the system used by both communication parties and the files to be transferred.
(3) Provides directory operations on local and remote computers.It can create or delete directories, change the current working directory and print the list of directories and files on the local computer or remote computer, and complete operations such as renaming, deleting and displaying the file contents.
3 .FTP Client Program
There are many kinds of client software that can complete the FTP function, including character interface and graphical interface. The commonly used FTP client software includes Cuteftp, WS ftp, etc. This article was published in Shangpin China UEOMarketing website constructioncompany//ihucc.com/