Socket communication has communication rules. If you want to maintain a persistent connection, you should have a communication protocol, including writing \ 0, which is also part of the rule. After a file is uploaded, wait for the next one. to maintain persistent connections, you can use WebService, so that your protocol becomes more readable and easier to package into products.
Look at yourProgramIf you want the read to end, it doesn't seem like you want to keep the persistent connection.
Frequent Connection reset by peer: there may be many reasons, but the more common reasons are:
①: When the number of concurrent connections on the server exceeds its capacity, the server will shut down some of the connections;
②: The client closes the browser, and the server is still sending data to the client;
③: The browser presses stop.
Many people say that it is caused by the client and there is no way to control it. This is a depressing problem.
This is caused by network connection disconnection. Generally, the firewall has a timeout mechanism. When the network connection does not transmit data for a long time, the TCP session is cut off, this will cause Connection reset by peer error.