Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. I/O Completion Port

I/O Completion Port

Scheduled Pinned Locked Moved C / C++ / MFC
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    unknown soldier
    wrote on last edited by
    #1

    Worker threads are associated with I/O completion port. Whenever I/O operation completed a thread is invoked. Now when this thread is invoked, how we come to know that which "type" of operation completed whether "read" or write". I think this has to be determined by overlapped structure but i don't know that which "field" of this structure informs about the "type" of operation completed.

    L 1 Reply Last reply
    0
    • U unknown soldier

      Worker threads are associated with I/O completion port. Whenever I/O operation completed a thread is invoked. Now when this thread is invoked, how we come to know that which "type" of operation completed whether "read" or write". I think this has to be determined by overlapped structure but i don't know that which "field" of this structure informs about the "type" of operation completed.

      L Offline
      L Offline
      Len Holgate
      wrote on last edited by
      #2

      bakhtawar wrote: Worker threads are associated with I/O completion port. Whenever I/O operation completed a thread is invoked. Now when this thread is invoked, how we come to know that which "type" of operation completed whether "read" or write". I think this has to be determined by overlapped structure but i don't know that which "field" of this structure informs about the "type" of operation completed. What usually happens is that you don't actually pass only an "overlapped" structure, you pass something that has an overlapped structure in it and also contains other stuff. This allows you to pass anything you like to your thread. Then, once inside your thread you simply convert back from the pointer to the portion of your structure that is an "overlapped" to a pointer to your structure. If you're using C++ then you might define your overlapped like this: class MyOverlapped : public OVERLAPPED { // include your own data here. }; And then pass it to a read request like this: MyOverlapped *pBuffer; if (SOCKET_ERROR == ::WSARecv( pSocket->m_socket, pBuffer->GetWSABUF(), 1, &dwNumBytes, &dwFlags, pBuffer, NULL)) and retrieve it from MyOverlapped *pBuffer = 0; GetQueuedCompletionStatus(m_iocp, &dwIoSize, (PDWORD_PTR)&pSocket, (OVERLAPPED**)&pBuffer); See the code for my reusable C++ socket server class for full details. Len Holgate www.jetbyte.com The right code, right now.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups