문제

I am doing a program with Winsock to create a client and send data to a server in response to which server replies with a specific data block received, this is continued a number of times.

The problem is some times my data block 1 gets overlapped with data block 2 so I want to flush out my TCP reception buffer after the 1st complete reception.

I reffered to this link also How do I "flush" a TCP Client Buffer? but I cant wait till the reception occurs

How can I flush the TCP receive data buffer? I am doing my project in visual c++

도움이 되었습니까?

해결책

The only way to "flush" the receive buffer is to read from it. After the first read, keep reading from the socket, throwing that data away, until there is no more data available to read. Use select() with a timeout to detect when the socket is still receiving data.

If data is being "overlapped" then either the server is not sending the data correctly on its end (overlapping send() calls), or you are not reading the data correctly on your end.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top