Shoutbox

Winsock & I/O Completion Ports - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Winsock & I/O Completion Ports (/showthread.php?tid=82438)

Winsock & I/O Completion Ports by andrewdodd13 on 03-18-2008 at 02:40 PM

I've got some (read: a lot) of code that I'm kind of in a muddle over. Basically, it's a server program which is designed to handle lots of concurrent connections which uses Winsock2 and I/O Completion Ports.

The main body of the WorkerThread gets an object from the Completion Queue [type CClientDS] and then does some work based on it's current state. Generally work is defined as READ from socket then SEND response.

The problem I'm having is with this bit of code:

code:
iResult = WSARecv(pClientDS->GetSocket(), p_wbuf, 1, &dwBytes, &dwFlags, p_ol, NULL);

if(iResult == SOCKET_ERROR && WSAGetLastError() != WSA_IO_PENDING) {
    logMessage(iThreadID, "si", "Client disconnected. ", WSAGetLastError());
    pClientDS->SetOpCode(INVALID);
} else if (WSAGetLastError() == WSA_IO_PENDING) {
    // This procs. And I don't know what to do about it
}

Basically, as you can probably see from the comment, the IO operation is still pending, but I don't know what to do! I tried putting break; here, but then we never get this item from the Completion Queue again.

I can't act on the p_wbuf buffer until I know I have the correct data.

Anyone know what to do? Help would be much appreciated.