其他分享
首页 > 其他分享> > 结束握手

结束握手

作者:互联网

结束握手

https://tools.ietf.org/html/rfc6455#section-1.8

1.4. Closing Handshake


   _This section is non-normative._

   The closing handshake is far simpler than the opening handshake.

   Either peer can send a control frame with data containing a specified
   control sequence to begin the closing handshake (detailed in
   Section 5.5.1).  Upon receiving such a frame, the other peer sends a
   Close frame in response, if it hasn't already sent one.  Upon
   receiving _that_ control frame, the first peer then closes the
   connection, safe in the knowledge that no further data is
   forthcoming.

   After sending a control frame indicating the connection should be
   closed, a peer does not send any further data; after receiving a
   control frame indicating the connection should be closed, a peer
   discards any further data received.

   It is safe for both peers to initiate this handshake simultaneously.

   The closing handshake is intended to complement the TCP closing
   handshake (FIN/ACK), on the basis that the TCP closing handshake is
   not always reliable end-to-end, especially in the presence of
   intercepting proxies and other intermediaries.

   By sending a Close frame and waiting for a Close frame in response,
   certain cases are avoided where data may be unnecessarily lost.  For
   instance, on some platforms, if a socket is closed with data in the
   receive queue, a RST packet is sent, which will then cause recv() to
   fail for the party that received the RST, even if there was data
   waiting to be read.

 

标签:control,handshake,结束,握手,peer,closing,data,frame
来源: https://www.cnblogs.com/yuanjiangw/p/12956269.html