Is attempting to connect a server, for example, using the Winsock connect port 8155 (the actual no application on this port service), the process is as follows:
Client - & gt; Server: the SYN
Server - & gt; Client: ACK SYN
Client - & gt; Server: ACK
Server - & gt; Client: ACK Reset
While the server side because there is no application to provide services on this port, the server will send a Reset message, so, the TCP is the "in fact disconnect",
But the Winsock connect function actually shamefully returned to their success, success! Then the send is successful, success! Recv unexpectedly also won't have mistakes happen! Just a Timeout,
Then, I went through the MSDN and baidu, don't know how to deal with this situation; Now find the Winsock seems to be completely ignored in this case, you want to send, just send it (and told you send success), send several times after, found that the server side no response (ACK), Winsock just waking up, and then to the server sends an ACK Reset, this, you recv again, is returning WSAECONNRESET error! Tell you: the An existing connection was forcibly closed by the remote host. The funny is good? Because the server have told you reset, but you turn a blind eye, don't want to send data, send an ACK found none, resend again and resend again, then, yi, the server has been without an ACK, it only said connection was forced to shut down the server,
CodePudding user response:
That you don't use winsock, directly use sokcet APICodePudding user response:
Google or baidu search light is meaningless, it involves the underlying the implementation of the TCP/IP protocol stackYou obviously have not read the TCP/IP protocol (1-3
CodePudding user response: