When calling WSASend()
, I have to pass it a WSAOVERLAPPED
instance, and I cannot re-use this WSAOVERLAPPED
instance until the previous WSASend()
operation has been completed (i.e. when a completion packet has been placed in the completion port).
Is there a way I can know if the WSASend()
operation has been completed without calling GetQueuedCompletionStatus()
?
You can use WSAGetOverlappedResult
to get the WSASend
progression:
/* size bytes to send */
WSASend(Sock, &aBuf, 1, NULL, 0, &overlap, NULL);
/* warning no test for error cases */
DWORD dummy;
DWORD sent;
do
{
/* Ask for the sending progression without waiting */
WSAGetOverlappedResult(Sock, &SendOverlapped, &sent, FALSE, &dummy);
/* to prevent too much CPU usage */
Sleep(15);
} while (size != sent);