TCP --- the difference between long and short connection connection

1. What is the long and short connection connection

Long connection

Long connection, also known as persistent connections, TCP layer after the handshake is successful, do not immediately disconnect and multiple messages on the basis of this connection (including heartbeat) interaction until either (client OR server) connection interrupts the connection, this process is called a full length connection. HTTP 1.1 with respect to the most important new features in 1.0 is the introduction of a long connection.

Short connection

 

After a short connection, by definition, a long connection with the difference is that the client receives the response server, and immediately send FIN messages , take the initiative to release the connection. Active server also connected off the situation, usually in a message exchange (retransmission request - in response to receiving) immediately after it is disconnected are called short connection.

 

Note: The short connection is based on the TCP protocol, a complete shake hands waving process, different from the UDP protocol.

 

 

2, how to quickly distinguish the current connection using a long or short connection connection

1. all in a complete message exchange (retransmission request - in response to receiving) Immediately thereafter, disconnects (one party send a FIN message case) are called short connection ;
2. A distinctive feature is that there is a long connection heartbeat message (there is no heartbeat), and generally in about 30S heartbeat interval or 1MIN, can be seen with wireshark capture interacting regular heartbeat message (milliseconds may exist a level of error).
 

3, when connected with the long and short connection?

1, requires frequent interaction scenes using long connection, such as instant messaging tools (micro-channel / QQ, QQ also UDP), the opposite is the use of short connections, such as a common web site, only when a browser initiates a request will establish a connection to the server after returning the corresponding, immediately disconnected.
2, to maintain a long connection there will be some overhead, the user is less easy to see that the system is not the bottleneck, once the user volume up, and it is likely the server resources (memory / CPU / NIC) is depleted, so use caution.

Guess you like

Origin www.cnblogs.com/Paul-watermelon/p/11141422.html