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