Write the FTP server and client Program Always encounter such errors and difficulties. Now we have solved most of the problems. The following is a record of some gains:
1. Understand the fundamental differences between active and passive modes:
Active Mode: the server knocks on the door to the client and then opens the door;
Passive Mode: the client knocks on the server, and the server opens the door.
2. The send method of socket is non-blocking;
3. ASCII transmission mode and binary transmission mode. For ASCII transmission mode, it is very convenient to transmit a small amount of data, but it is used to transmit a large amount of data, such as large files, it is not easy for the receiver to process.
In my design, only the binary mode can ensure that each transmission is correct. In particular, the sendfile method of socket is used, which is a blocking method. As long as the data is not sent, it will be blocked until the sending is complete. The system automatically handles buffering and other issues, which is very convenient; it belongs to binary mode.
4. Understand the necessity of a protocol standard.
5. Learned a lot of FTP commands.
6. I have mastered the working principle and Programming Method of socket.
7. I have further understood multithreading programming.
8. FTP is the abbreviation of File Transfer Protocol (file transfer protocol), used to transfer files between two computers. The FTP protocol is much more complex than HTTP. The reason for the complexity is that the FTP protocol requires two TCP connections. One is the command link used to transmit commands between the FTP client and the server, and the other is the data link used to upload or download data.
(1) The two sockets used to send commands are connected throughout the process;
(2) Two sockets used for data transmission. A connection is established only when data is transferred. After data is transferred, the connection is disconnected.
(3) There are two sockets used for listening. When the active mode is used, clientlistener is in the listening state; when the passive mode is used, serverlistener is in the listening state.
So much for the time being. It's too late to go to bed .... Zzzzzzzzzzzzzzzzzz
References:
1. active FTP vs. Passive FTP authoritative explanation
2. FTP Response Code
3. FTP Wiki
4.Understand FTP service and FTP protocol (figure)
5.One FTP class
6.C # Of an FTP Client #Code2
7.FTP protocol analysis and Expansion
8.FTP commands
9.Http://www.faqs.org/rfcs/rfc959.htmlRFC 959 (rfc959)Chinese Version
10.FTP-File Transfer Protocol
Other resources:
FTP protocol cluster
Http://www.ietf.org/rfc/rfc959.txt
Http://www.ietf.org/rfc/rfc1579.txt
FTP Security Extension
Http://www.ietf.org/rfc/rfc2228.txt
Http://www.ietf.org/rfc/rfc2246.txt
FTP Security Extension, draft SSL interface:
Http://www.ietf.org/internet-drafts/draft-murray-auth-ftp-ssl-13.txt
SSL/TLS specifications:
Http://www.ietf.org/rfc/rfc2246.txt
OpenSSL, a widely used SSL implementation:
Http://www.openssl.org
FTP client supporting SSL ftp:
Http://www.ford-hutchinson.com /~ Fh-1-pfh/ftps-ext_col.html # Client
FTP server that supports SSL ftp:
Http://www.ford-hutchinson.com /~ Fh-1-pfh/ftps-ext_col.html # Server