September 15th, 2011, 10:23 PM
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
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
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.
Tags for this Thread
Click Here to Expand Forum to Full Width