完成端口GetQueuedCompletionStatus()返回错误,怎样获得真正的错误代码

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;
}

使用了WSAGetOverlappedResult()函数,封装一下就可以用在代码里了:)

你可能感兴趣的:(完成端口GetQueuedCompletionStatus()返回错误,怎样获得真正的错误代码)