Discuss the abnormal disconnection of TCP connections and their processing

xiaoxiao2021-03-06  58

Discussion on the abnormal disconnection of TCP connections: (assuming two different host systems C, D) CT, DT there is a TCP connection).

1. The process is extremely terminated. CT is extremely terminated and C is normal, the TCP connection is closed by C and immediately tells D, and DT will soon be seen that this TCP connection is abnormally closed. This exception is known in the Socket call when programming, and the programmer can process it simple.

2. The system is extremely terminated. This includes two cases of host system crash, and host network hardware disconnect (for example, unplug the network cable). Suppose the C system is abnormal, and D cannot know the failure of this TCP connection and always think is normal. This situation will become very bad when programming, because the TCP connection will always be considered valid, all the calls to this TCP Socket will return correctly, which is obviously wrong. This error usually lasts for a long time, even if the SOCKET's SO_KEEPALIVE attribute is set, it is necessary to wait for 2 hours by default. If DT is a server program, which is ftp, it is impossible (there is no significant impact on it exists in 2 hours). If it is necessary to know the instant messaging class server that connects to the user status in real time is a problem. The problem of the former does not necessarily solve it, the latter's solution is generally a server program and client program to reach a certain protocol, and the client timed to send a small packet to the server (remember 'online status update') to tell yourself. Status, and server-side programs need to update the user's timeout time count after receiving the user's 'online status update', and when the user's time count exceeds the specified time, it can be considered that this user has already 'system anomaly termination'. The connection between the termination and the other user. Then the CT is discussed. When the CT is definitely died in the system crash, there is no need to deal with it. It is the same as the DT in the case of network hardware. It will also use the DT processing method.

转载请注明原文地址:https://www.9cbs.com/read-113888.html

New Post(0)