EDIT: No matter, figured it out. Seems it's the console output consuming all that time... reminds me why I don't like using the std lib. (Freely move to the trash can :))
Either I'm implementing them wrong, or they're extremely inefficent.
I did a simple test of transfering 2MB locally with both an IOCP and standard recv(). It took the recv() under 16ms, while the IOCP took 1,500ms+. I must admit I think I'm implementing IOCP wrong, I would think it's impossible to take anywhere near a second to receive data from a local endpoint.
NOTE: This is my first attempt using IOCP, one of the Window's concepts I never delved into till now.
(IOCP)
for(;;)
{
dwStartTime = GetTickCount();
if(WSARecv(hClient, &Buf, 1, &dwReceived, &dwFlags, &Overlapped, NULL) == SOCKET_ERROR)
{
if((dwError = GetLastError()) != 997)
{
std::cout << "Error = " << GetLastError() << std::endl;
}
}
else
{
if(dwReceived)
{
std::cout << "Immediate completion (dwReceived = " << dwReceived << ")\n";
dwTotal += dwReceived;
}
}
dwOther += GetTickCount() - dwStartTime;
dwStartTime = GetTickCount();
// wait
if((dwEnd = GetQueuedCompletionStatus(IoPort, &dwReceived, &dwKey, &pOverlapped, INFINITE)) != 0)
{
std::cout << "Async Completed (dwReceived = " << dwReceived << ")\n";
}
else
{
dwTotal += GetLastError();
}
dwMaxTime += GetTickCount() - dwStartTime;
if(dwTotal >= 2000000) break;
}
(Standard recv(). (Synchronous/blocking)
for(;;)
{
dwTotal += recv(hClient, (char*) Data, 20000, NULL);
if(dwTotal >= 2 000 000) break;
}
Excuse the sloppy code, just testing.
Note that, it seems WSARecv(...) is consuming most of the time (1,300ms+).