I wrote a section in C LanguageProgram, Run on the client to request files on the server. Sometimes, when the send command is sent, the returned value of read is-1 and the errno value is Connection reset by peer.
In the TCP mechanism, both parties of the socket connection can call functions such as close () to exit the current connection. Based on the improved three-way handshake mechanism, TCP notifies the other party to exit the current connection. This process can be seen as part of a normal socket connection.
At the same time, TCP provides a reset mechanism to send a reset packet to the other party after a program disconnects the connection in case of an exception. Reset is to immediately exit and clear all resources related to this connection.
Therefore, Connection reset by peer occurs because the peer server unexpectedly exits the connection.
In this case, the client only needs to reconnect to the server. In this case, sometimes I have to try again about five times to connect normally.