In TCP normal interaction messages, it is usually ACK, SYN, FIN and so on. In special cases, an RST message is received. The receiving of this message means that the other end notifies the other end that it needs to close its connection.

This end receives RST message in several cases:

  1. The client connects to a port that does not exist on the server. The server sends the RST to the server
  2. When a client tries to connect to a server port and is in TIME_WAIT state, the server sends RST to the client
  3. Proactively send RST, drop send buffer data, abnormally terminate the connection
  4. Write data to a half-open connection and it will reply with an RST. For example, when a client and server on different machines are connected normally, suddenly unplug the network cable between them, and then restart the server. During this process, the client is unaware of the exception on the server side and remains connected (in this case, partially open). The client writes data to the connection, and the rebooted server receives it and replies to RST

RST related processing:

  1. Send the RST to clear the remaining send queues
  2. Receive RST, close connection or reconnect, no response