TCP shutdown/close on LinuxThe Linux version is kernel-2.6.21:1. As long as there is unread (read) data in the read buffer of the TCP stack, the RST is sent directly to the peer when close is called. 2.shutdown does not have a relationship with the socket descriptor, even if the call to shutdown (FD, SHUT_RDWR) does not close the FD, and eventually close (FD) is required. 3. Shutdown (FD, SHUT_RD) can be considered an empty operation, since shutdown can continue to read data from the socket, which may require further confirmation. 4. Write the socket descriptor after the fin package has been sent raises epipe/sigpipe. 5. When multiple socket descriptors point to the same socket object, when close is called, the reference count of the object is decremented first, and the FIN packet end TCP connection is not sent until 0 o'clock. Shutdown different, as long as the Shut_wr/shut_ The fin packet is sent by the RDWR mode call. 6.so_linger and Close, when the So_linger option is on but the timeout value is 0 o'clock, call close to send the RST directly (this avoids entering the time_wait state, but destroys the way the TCP protocol works), So_ Linger has no effect on shutdown. There is no direct relationship between the RST on the 7.TCP connection and the subsequent possible time_wait state, the active fin outsourcing will inevitably enter the TIME_WAIT state unless the fin is sent directly to end the connection with the RST.
Shutdown/close of TCP on Linux