About the three-time handshake when the TCP connection was established, why not 2 or 4 times 5 times

Source: Internet
Author: User

First, the process of "three handshake" in the process of TPC connection establishment is briefly described:


First: client sends connection request like server side

Second time: After the server receives the request, it sends a response and connection request to the client

Third time: After the client receives a request to the server to send a reply

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/84/8A/wKiom1eTb3nAmFTHAAE4wfb_cAk708.png "title=" 1.png " alt= "Wkiom1etb3namfthaae4wfb_cak708.png"/>





A total of 3 messages were sent, so the process is also known as the "three handshake"

and 3 of these handshakes are the minimum number of messages that need to be sent during the connection process.


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/84/89/wKioL1eTb76T8wLLAAIjmL_sZbY842.png "title=" 2.png " alt= "Wkiol1etb76t8wllaaijml_szby842.png"/>


In this view:

1:

Once a handshake is sent only once by the client, it is certainly not possible to establish a reliable TCP connection



2:

Two handshake: The server does not know if it can send the message, and whether the client on the opposite side can receive it. That is, if the connection is established in the two-time handshake, it is likely that the connection is one-way from the client to the server, that is, the client has been sending messages and the server has been receiving messages.


In addition, the two-time handshake establishes the connection, the server side if sends the message to the client, cannot guarantee to send normally, also cannot guarantee the client to receive normally. So two handshakes can cause both cases: (c means client, s means server side)

1, the process of establishing a connection, C sends a request to s, but for some reason, S did not receive the request, so C sent a request.

S responds to C and makes a request. This time the connection is established, the communication begins, and the connection is terminated. At this point, the first

s did not receive the request suddenly reached the S-end, so s response to this request, due to the assumption of "two times handshake", this time

S thinks that he and C have established a connection, but C does not consider itself and s to establish a connection, which causes the failed request to reestablish the wrong connection



2. If the server is issued and the client does not receive the message, the server repeats the message until it gets a response, wasting a lot of resources


3:

4, 5, 6, 7 handshake: Since the 3-time handshake has ensured a reliable connection, there is no need for multiple handshakes




About the three-time handshake when the TCP connection was established, why not 2 or 4 times 5 times

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.