Posted on 2009-05-29 21:55
S.l.e!ep.¢% 閱讀(845)
評論(0) 編輯 收藏 引用 所屬分類:
IOCP
if (SI->BytesRECV > SI->BytesSEND)
?? {
????? // Post another WSASend() request.
????? // Since WSASend() is not gauranteed to send all of the bytes requested,
????? // continue posting WSASend() calls until all received bytes are sent.
????? ZeroMemory(&(SI->Overlapped), sizeof(WSAOVERLAPPED));
????? SI->DataBuf.buf = SI->Buffer + SI->BytesSEND;
????? SI->DataBuf.len = SI->BytesRECV - SI->BytesSEND;
????? if (WSASend(SI->Socket, &(SI->DataBuf), 1, &SendBytes, 0,
???????? &(SI->Overlapped), WorkerRoutine) == SOCKET_ERROR)
????? {
???????? if (WSAGetLastError() != WSA_IO_PENDING)
???????? {
??????????? printf("WSASend() failed with error %d\n", WSAGetLastError());
??????????? return;
???????? }
????? }
?? }