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+weird latency problem

IOCP+weird latency problem

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

    Hi, again a question about me with my IOCP skills :) ok, the situation is the following, everything works perfectly except for 1 thing, a really weird thing if you ask me. I'm currently testing so i use 1 WorkerThread with 1 udp virtual connection at the time. When i do a WSARecvFrom, i should recieve a buffer with a size of lets say 600 bytes. This hapends idd but later, here is my thing: GetQueuedCompletionStatus(...) DWORD ioSize = 0; case RequestSend: //WSASendTo and set to AfterSend break; case AfterSend: //Sended 8 bytes, now recieve with WSARecvFrom and set to AfterRecieve ioSize = static_cast(lpOverlapped->InternalHigh); break; case AfterRecieve: ioSize = static_cast(lpOverlapped->InternalHigh); //do rest This is the things i do, now it happends that in AfterRecieve, ioSize is the same as the size when i sended. better said, the data aint recieved yet, however i do get a notification that the data is recieved. When i put a breakpoint at that point, i see that the data is deliverd, to pull a conclusion, I get a notification when the data is recieved well it isnt untill i put a breakpoint at that place, really weird weird story so: dwIoSize = static_cast(ptrOverlapped->InternalHigh); ptrSession->incRecvBytes(dwIoSize); if ((iTemp = ptrGameClass->UnpackServerInfo(ptrSession->getNDServer(), &objToolset)) == 0){//Session is finished! pThis->FinishGame(ptrSession->getNDServer()); __REPORT("SUCCEEDED"); } else if (iTemp < 0){ __REPORT("%s->UnpackServerInfo() failed", ptrGameClass->Gamename()); } To make it even more clear, whenever i put a breakpoint at: ptrSession->incRecvBytes(dwIoSize);, dwIoSize is 8 as the send buffer, but ptrOverlapped->InternalHigh is like 600 bytes. When i do reports, it just reports that ptrOverlapped->InternalHigh is 8

    M 1 Reply Last reply
    0
    • P Polity4h

      Hi, again a question about me with my IOCP skills :) ok, the situation is the following, everything works perfectly except for 1 thing, a really weird thing if you ask me. I'm currently testing so i use 1 WorkerThread with 1 udp virtual connection at the time. When i do a WSARecvFrom, i should recieve a buffer with a size of lets say 600 bytes. This hapends idd but later, here is my thing: GetQueuedCompletionStatus(...) DWORD ioSize = 0; case RequestSend: //WSASendTo and set to AfterSend break; case AfterSend: //Sended 8 bytes, now recieve with WSARecvFrom and set to AfterRecieve ioSize = static_cast(lpOverlapped->InternalHigh); break; case AfterRecieve: ioSize = static_cast(lpOverlapped->InternalHigh); //do rest This is the things i do, now it happends that in AfterRecieve, ioSize is the same as the size when i sended. better said, the data aint recieved yet, however i do get a notification that the data is recieved. When i put a breakpoint at that point, i see that the data is deliverd, to pull a conclusion, I get a notification when the data is recieved well it isnt untill i put a breakpoint at that place, really weird weird story so: dwIoSize = static_cast(ptrOverlapped->InternalHigh); ptrSession->incRecvBytes(dwIoSize); if ((iTemp = ptrGameClass->UnpackServerInfo(ptrSession->getNDServer(), &objToolset)) == 0){//Session is finished! pThis->FinishGame(ptrSession->getNDServer()); __REPORT("SUCCEEDED"); } else if (iTemp < 0){ __REPORT("%s->UnpackServerInfo() failed", ptrGameClass->Gamename()); } To make it even more clear, whenever i put a breakpoint at: ptrSession->incRecvBytes(dwIoSize);, dwIoSize is 8 as the send buffer, but ptrOverlapped->InternalHigh is like 600 bytes. When i do reports, it just reports that ptrOverlapped->InternalHigh is 8

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

      For socket operations you should't be touching (or looking at) anything in the OVERLAPPED structure. None of it applies to IOCPs and especially the "Internal" fields which are for use by the system so they have NO meaning to your code. Ok, you can look at them, but don't expect any specific values :) I would suggest clearing the OVERLAPPED struct to 0s before every operation. If you need to add your own fields (I'm not sure how one would do overlapped ops without doing this) then define your own struct which includes an OVERLAPPED struct. You may have seen these, but here's a couple articles that helped me alot when I first used an IOCP... Writing Windows NT Server Applications in MFC Using I/O Completion Ports [^] Windows Sockets 2.0: Write Scalable Winsock Apps Using Completion Ports[^] INFO: Design Issues When Using IOCP in a Winsock Server[^] And this one's in the online help - <--edit -- modified at 13:21 Tuesday 16th January, 2007

      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