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. IOCP and ERROR_IO_PENDING

IOCP and ERROR_IO_PENDING

Scheduled Pinned Locked Moved C / C++ / MFC
questionsysadminhelptutorial
6 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.
  • P Offline
    P Offline
    Polity4h
    wrote on last edited by
    #1

    Hi, Im creating a server using UDP and IOCP. I've red some articles about it and i understand the most of it ( the basic anyway. not saying im a IOCP master ) anyway, since i got a lot of ERROR_IO_PENDING returns when doing a WSASendTo or WSARecvFrom, i got myself wondering what hapends when i get this error. I know what it means but i dont quit seem to get or find any information about how to process it. What hapends when a send or recv function returns this and what is the best way of processing it? Thanks already!

    M 1 Reply Last reply
    0
    • P Polity4h

      Hi, Im creating a server using UDP and IOCP. I've red some articles about it and i understand the most of it ( the basic anyway. not saying im a IOCP master ) anyway, since i got a lot of ERROR_IO_PENDING returns when doing a WSASendTo or WSARecvFrom, i got myself wondering what hapends when i get this error. I know what it means but i dont quit seem to get or find any information about how to process it. What hapends when a send or recv function returns this and what is the best way of processing it? Thanks already!

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Most, if not all, of of your overlapped operations on a socket associated with an IOCP should return this "error". It means that the overlapped operation was queued for processing by the IOCP and when the operation is complete then one of the threads waiting on the IOCP (via GetQueuedCompletionStatus()) will be released. When a thread receives the completion notification (GetQueuedCompletionStatus() returns) then you can check if an error occurred. If the operation was successful do whatever processing needs to be done (perhaps destroying the send/recv buffer, returning it to a buffer pool, queuing up another overlapped operation, etc). Any other error than ERROR_IO_PENDING means the operation was NOT queued so you'll never get a completion notification. In other words, the operation failed immediately. Mark

      P 1 Reply Last reply
      0
      • M Mark Salsbery

        Most, if not all, of of your overlapped operations on a socket associated with an IOCP should return this "error". It means that the overlapped operation was queued for processing by the IOCP and when the operation is complete then one of the threads waiting on the IOCP (via GetQueuedCompletionStatus()) will be released. When a thread receives the completion notification (GetQueuedCompletionStatus() returns) then you can check if an error occurred. If the operation was successful do whatever processing needs to be done (perhaps destroying the send/recv buffer, returning it to a buffer pool, queuing up another overlapped operation, etc). Any other error than ERROR_IO_PENDING means the operation was NOT queued so you'll never get a completion notification. In other words, the operation failed immediately. Mark

        P Offline
        P Offline
        Polity4h
        wrote on last edited by
        #3

        ok, i see that makes it all clear. In a related question, when i have multiple threads and when i do a WSASendTo or whatever, it returns -1 so i use WSAGetLastError(). to retrieve the error. Does WSAGetLastError() returns the last error associated with that specific thread, or could it happen that 2 threads at the same time store an error and that i might retrieve an error from another thread with WSAGetLastError()? ( doest seems likely but who knows)

        M 2 Replies Last reply
        0
        • P Polity4h

          ok, i see that makes it all clear. In a related question, when i have multiple threads and when i do a WSASendTo or whatever, it returns -1 so i use WSAGetLastError(). to retrieve the error. Does WSAGetLastError() returns the last error associated with that specific thread, or could it happen that 2 threads at the same time store an error and that i might retrieve an error from another thread with WSAGetLastError()? ( doest seems likely but who knows)

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          Yes WSAGetLastError() returns the error code for the last socket API called on the calling thread. Mark

          1 Reply Last reply
          0
          • P Polity4h

            ok, i see that makes it all clear. In a related question, when i have multiple threads and when i do a WSASendTo or whatever, it returns -1 so i use WSAGetLastError(). to retrieve the error. Does WSAGetLastError() returns the last error associated with that specific thread, or could it happen that 2 threads at the same time store an error and that i might retrieve an error from another thread with WSAGetLastError()? ( doest seems likely but who knows)

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            And....especially for overlapped calls, you should check the error EVERY time the API indicates an error. Otherwise there's no way to effectively manage the overlapped buffers. :) Mark

            P 1 Reply Last reply
            0
            • M Mark Salsbery

              And....especially for overlapped calls, you should check the error EVERY time the API indicates an error. Otherwise there's no way to effectively manage the overlapped buffers. :) Mark

              P Offline
              P Offline
              Polity4h
              wrote on last edited by
              #6

              ok, thnx :)

              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