Analysis of the status of TIME_WAIT of TCP/IP a server crashes some time ago. The reason is that the program cannot create a SOCKET connection due to the excessive number of TCP connections on the server. Finally, the problem is solved. When locating the problem, check the number of TCP connections in the operating system. Hundreds of connections are in the TIME_WAIT status. What does TIME_WAIT mean? So I checked the TCP protocol again and finally clarified it. Here I will record it. The following figure shows the status change of the TCP/IP. We can see that there are three situations in which TCP is recommended to be In the TIME_WAIT status after a connection, but in either case, it must have initiated an active shutdown, and the other party's FIN has been received. At this time, the TIME_WAIT status is entered. The TIME_WAIT status time is twice the MSL (maximum survival time). In the TIME_WAIT status, the TCP connection is actually disconnected, but the plug-in cannot be used by new connection instances. In this case, a large number of short connections are established in the program, and port usage can be restricted in the operating system, so it is very likely that the number of connections is full (such as java.net in java. socketException No buffer space available (maximum connections reached? Exception ). You can change the value of TcpTimedWaitDelay to shorten the TIME_WAIT status time. So why do we need the TIME_WAIT status? An important reason is to prevent the ACK loss of the FIN to the other party. Because the server does not confirm the ACK, it can only wait for a while for the server to receive it. If the server does not receive the confirmation of its FIN, it will continue to send a FIN, in this way, the client still has the opportunity to continue to return an ACK. Another reason is to prevent the new connection from being affected by the late data packets in the last connection, and these packets will be discarded in the TIME_WAIT status.