GetQueuedCompletionStatus()返回错误,说明I/O失败。此时调用GetLastError()得到的往往是ERROR_NETNAME_DELETED(64),WSAGetLastError()也一样,这显然不是真正的错误代码,那么怎么得到真正的错误代码呢?
int YourIOCPClass::GetSockError(WSAOVERLAPPED* pWSAOVERLAPPED)
{
DWORD dwTrans;
DWORD dwFlags;
if(FALSE == WSAGetOverlappedResult(m_IOSock, pWSAOVERLAPPED, &dwTrans, FALSE, &dwFlags))
return WSAGetLastError();
else
return ERROR_SUCCESS;
}