-
September 15th, 2011, 10:23 PM
#1
Simple IOCP Model Question
Hey everyone, I'm starting to mess with the IOCP model for server/client interactions. One thing that is weird to me, and I'm not sure if this is proper, but to make the client or server properly receive data I have to use
Code:
PostQueuedCompletionStatus
as soon as a connection is accepted or if the client/server is connecting out, AND I have to use it again when I complete an read or write operation. Is this how it is supposed to be? Or should this not be required?
-
September 19th, 2011, 08:33 PM
#2
Re: Simple IOCP Model Question
Generally, it should not be required. With IOCPs, the I/O operation posts its own completion on the port. For example, when calling WSARecv(), the return value is normally SOCKET_ERROR with a WSAGetLastError of WSA_IO_PENDING. There is nothing more to do, except wait on a call to GetQueuedCompletionStatus, which will return when overlapped I/O operations complete.
There are some uses for PostQueuedCompletionStatus, such as to send a "special" message to threads waiting on GetQueuedCompletionStatus, such as a message that the server should shut down. But in general, there are very few reasons for the call. If you find a need to use it often, then you are probably doing something wrong.
Mike
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|