CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2011
    Posts
    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?

  2. #2
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    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
  •  





Click Here to Expand Forum to Full Width

Featured