当调用WSASend()时,我必须向它传递一个WSAOVERLAPPED实例,并且在前一个WSAOVERLAPPED操作完成之前(即,在完成端口中放置了一个完成数据包),我不能重新使用这个WSASend()实例。
有没有办法让我知道WSASend()操作是否已完成而不调用GetQueuedCompletionStatus()

最佳答案

您可以使用WSAGetOverlappedResult获得WSASend进展:

/* 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);

10-06 02:04