重叠套接字 IO 中的错误处理
在使用重叠套接字 IO 和 IOCP 的情况下,任何人都可以建议一种可靠的方法来处理系统错误吗?
MSDN在这方面的描述很繁琐。它表示对于 GetQueuedCompletionStatus
返回代码 FALSE,应该有一个后续的 GetLastError
调用来获取失败操作的错误代码。然而,我们知道对于 WSA 函数,应该调用 WSAGetLastError
(GetLastError
在套接字错误时返回 0)。所以问题的第一部分是——它在实践中是如何运作的?
另一个问题是如果通过 GetQueuedCompletionStatusEx 提取完成数据包,则处理错误。 MSDN 仅描述了此调用本身的错误处理,而没有提及获取各个失败操作的错误代码。
预先感谢所有回复和评论。
Can anyone please suggest a reliable way to handle system errors in case of using overlapped socket IO and IOCP?
MSDN description is cumbersome on this aspect. It says that for GetQueuedCompletionStatus
return code FALSE there should be a subsequent GetLastError
call to get error code on the failed operation. However, we know that for WSA-functions one should call WSAGetLastError
instead (GetLastError
returns 0 upon a socket error). So the first part of question is - how does it work in practice?
Another problem is handling errors if completion packets are extracted by GetQueuedCompletionStatusEx
. MSDN describes only error handling for this call itself, saying nothing about obtaining error codes of individual failed operations.
Thanks in advance for all responses and comments.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过几个小时用放大镜试验和研究 MSDN 后,我发现了以下内容:
http://msdn.microsoft.com/en-us/library/ms684342%28v=VS.85%29.aspx(一篇关于重叠结构的文章,
内部描述字段):
最后一句话看起来不太好,但我想就是这样。
After few hours of experimenting and studying MSDN with a magnifying glass I've found the following:
http://msdn.microsoft.com/en-us/library/ms684342%28v=VS.85%29.aspx (an article on OVERLAPPED structure, description of the
Internal
field):The last phrase doesn't look good, but I guess it is what it is.