FTP-like File Transfer Mechanism

Source: Internet
Author: User
1. Open two ports on the server. One is to listen to commands and the other is to transmit file data.
2. Connect the client to the listening port of the server, send the test connection command, and check whether the server is running normally. If the dialog is normally transferred to step 3, otherwise, terminate the dialog, or reconnect and check.
3. the server sends a confirmation message to the client through the command port to notify the client service to run normally, and checks local settings to determine whether files can be sent to the client. If you can go to the next step, otherwise, the cause of the error is sent to the client through the command port to stop the session. The client processes the received information, terminates all actions, or tries again.
4. the server sends the port number opened locally for file transfer to the client, and then the client connects to the server port through socket. At the same time, the client automatically selects a random port to connect to the server port. (Because in general, the server port should be fixed. In addition, when the socket connection is used, the server port is fixed, and the client port is randomly selected during the connection process. If you want the server to connect to the client, on the one hand, the server needs to develop too many ports, and the selection of ports is also very troublesome; on the other hand, the client may have a lot of restrictions, it needs to be set according to different situations)
5. Send the file to the client through the file transfer port.
6. When transferring a large file, it is generally divided into small pieces for transmission, because during the transfer process, data is stored in the memory, if every file is stored in the memory, memory overflow will soon occur.
7. In addition, multiple processes can be downloaded simultaneously. At this time, the same port is not used, because there are many channels in the same port, each file is transmitted through a channel without interfering with each other.

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.