Home > Software engineering >  Winsock how to detect TCP Reset state?
Winsock how to detect TCP Reset state?

Time:09-26

When using a TCP connection to a "no" port, some servers is can let you of the connection is successful, but will send a Reset after a message;

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 API

CodePudding user response:

Google or baidu search light is meaningless, it involves the underlying the implementation of the TCP/IP protocol stack
You obviously have not read the TCP/IP protocol (1-3

CodePudding user response:

refer to the second floor danscort2000 response:
light Google or baidu search is meaningless, it involves the underlying the implementation of the TCP/IP protocol stack
You obviously have not read the TCP/IP protocol (1-3

Baidu search less than
"TCP - IP, rounding a: agreement"
"TCP - IP, volume 2: implement"
"TCP - IP, volume 3: TCP transaction protocol, HTTP, NNTP and UNIX domain agreement"
The content of the inside?

CodePudding user response:

Make a heartbeat packets, used to detect,

CodePudding user response:

The problem should not be the WinSock,
Start WSAEventSelect FD_CLOSE events, wait for closed event,
Or thread recv continuously, processing & lt;=0

CodePudding user response:

reference zhao4zhong1 reply: 3/f
Quote: refer to the second floor danscort2000 response:

Google or baidu search light is meaningless, it involves the underlying the implementation of the TCP/IP protocol stack
You obviously have not read the TCP/IP protocol (1-3

Baidu search less than
"TCP - IP, rounding a: agreement"
"TCP - IP, volume 2: implement"
"TCP - IP, volume 3: TCP transaction protocol, HTTP, NNTP and UNIX domain agreement"
The content of the inside?

I doubt your ability to understand, I said is to understand or explain why in detail, the realization of the need to read and understand the TCP/IP layer,
Light Mao Yong search to content have? A few people take the effort to see this big?
  • Related