Significance of Abnormal TCP Shutdown

Source: Internet
Author: User

TCP-caused exception shutdown means that the normal method for terminating a connection is to send FIN. All queued data in the sending buffer is sent before sending FIN. Normally, no data is lost. However, sometimes we may send an RST packet segment instead of FIN to close a connection. This is called an exception closure. By default, the process closes the socket normally. If you need to disable it abnormally, use the SO_LINGER option to control it. Disabling an abnormal connection has two advantages for the Application: (1) discard any meaningless data to be sent and immediately send the RST packet segment; (2) the receiver of the RST uses the close method to identify whether the other end performs abnormal close or normal close. It is worth noting that the RST packet segment will not cause any response from the other end, and the other end will not be confirmed at all. The party receiving the RST will terminate the connection. The program behavior is as follows:
In the blocking model, the kernel cannot actively notify the application layer of errors. Only when the application layer actively calls IO system calls such as read () or write, the kernel sends an error to the application-layer peer RST. In a non-blocking model, select or epoll returns sockfd readable. When the application layer reads it, read () reports an error in RST. This option is used in the implementation of haproxy.

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: 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.