完成端口GetQueuedCompletionStatus返回值的问题
先看看GetQueuedCompletionStatus函数的完整声明:
BOOL GetQueuedCompletionStatus(
HANDLE CompletionPort,
LPDWORD lpNumberOfBytes,
PULONG_PTR lpCompletionKey,
LPOVERLAPPED *lpOverlapped,
DWORD dwMilliseconds
);
再看看MSDN上对其返回值的说明:
If the function dequeues a completion packet for a successful I/O operation from the completion port, the return value is nonzero. The function stores information in the variables pointed to by the lpNumberOfBytesTransferred, lpCompletionKey, and lpOverlapped parameters.
如果函数从完成端口取出一个成功I/O操作的完成包,返回值为非0。函数在指向lpNumberOfBytesTransferred, lpCompletionKey, and lpOverlapped的参数中存储相关信息。
If *lpOverlapped is NULL and the function does not dequeue a completion packet from the completion port, the ret

本文探讨了完成端口GetQueuedCompletionStatus返回值的问题,包括不同返回状态的处理方式,如错误码1236、1234、64等。遇到WSASEND/WSARECV成功但IO被重置,服务器主动关闭socket,以及其他IO失败的情况,需要区分IO类型来处理。特别地,当UDP接收请求失败,完成键有时为NULL,这与MSDN文档描述不符,可能引发程序崩溃,需要在重新投递接收请求时进行判断。
最低0.47元/天 解锁文章
2698





