Hi,
I am about to write server code for a GPRS connection. I was wondering when does the IO Completion port worker thread get the information? For example, if the server sends out a request to the GPRS system to send 50 bytes (which it does), how does the IO Completion port knows how much data to read before informing a worker thread?. Does the IO Completion port call a working thread when there is a timeout after the first character is read (and if the buffer is full)? As the worker thread doesn't get called when each byte is received.
Neil,
When your GetQueuedCompletionStatus() function unblocks, one piece of information returned is the number of bytes that have been received to this point. Pass this received data to your worker thread, Do another WSARecv, and wait for the GetQueuedCompletionStatus() to unblock again.
Basically, you will have some logic like this:
while(1)
{
BOOL status = GetQueuedCompletionStatus(...);
if(status)
{
//valid return so if we have data, call the worker thread
//if we are being told to shutdown, do so now
}
else
{
//IOCP failed ....maybe kill the socket and force a reconnect
}
}//end of while
The worker thread is part of your server class that does all the work with messages are received. As you have mentioned, you are never guaranteed to get all of the message at one time so you must allow for receiving partial messages and you must reassemble everything in the worker thread.
/dev/null helped me a lot in getting my IOCP application running so please continue to ask questions as your development continues, this list is an outstanding source for this information.
HTH
Regards, David Stroupe
_______________________________________________ msvc mailing list [EMAIL PROTECTED] See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription changes, and list archive.
