GetQueuedCompletionStatus()返回错误,说明I/O失败。此时调用GetLastError()或WSAGetLastError()得到的往往是ERROR_NETNAME_DELETED(64),这显然不是真正的错误代码,那么怎么得到真正的错误代码呢?代码如下
- int YourIOCPClass::GetSockError(SOCKET m_Socket ,WSAOVERLAPPED* pWSAOVERLAPPED/*重叠结构指针*/)
- {
- DWORD dwTrans;
- DWORD dwFlags;
- if(FALSE == WSAGetOverlappedResult(m_Socket, pWSAOVERLAPPED, &dwTrans, FALSE, &dwFlags))
- return WSAGetLastError();
- else
- return ERROR_SUCCESS;
- }