mercredi 26 juillet 2023

The TCP server send function blocks when the network cable is unplugged?

I encountered a problem: I implemented a TCP socket server. When listening to a client connection, I set a timer (another thread) to send data to the client, but the client does not send data to the server, and all APIs are blocked. When I use a TCP socket client tool to connect to the server, I can normally listen to data from the server. By manually closing the client and reconnecting, I can also listen to data from the server. However, this tool connects to the server and successfully connects and receives data. At this point, I disconnect the network cable and then connect it back. Once the connection is successful, I can no longer receive data, I have checked that my timer thread is working properly. The problem is that the send function in the timer thread is blocked. May I know how to handle this issue? I have set the TCP heartbeat.

Aucun commentaire:

Enregistrer un commentaire