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.