1) The client is in the fin_wait_1 state and the server is in the syn_recv state;
This is also a problem I encountered recently. The socket connection and disconnection procedures have been mentioned in the previous sections. You can refer to the previous sections;
How can this problem occur? The reason is that the client connects to the server, but the server limits the number of client access. It only listen does not have the accept action, causing the client to connect successfully each time, but the connection cannot be established, the client has done it again. If the data cannot be sent successfully, immediately closesocket and re-connect the new socket. This causes the above phenomenon. In socket FAQ 4, we can see the socket creation process. When the server listen connects to the client, it enters the syn_recv state. After listen, if a response is sent to the client, the client connection may be established, but after the client fails to send data, it will be closesocket and the client will enter the fin_wait1 State. At this time, the server does not have an ACCEPT, so there is no corresponding socket, the client does not send a response and closesocket information to the client. In this way, the client has a lot of fin_wait_1 and many syn_recv servers. This may cause other clients to be unable to connect, for example, you can turn off the client on my side and connect other clients;
Solution:
The connection of the server's accept client, based on the number of connections, if the number of connections exceeds, close this socket, so that this will not cause such a problem.