问题描述
在我的代码中,我具有带有I/O完成端口的异步I/O,对于读/写完成回调,我得到一个HANDLE
(当然可以是套接字,文件句柄,命名管道和等等).
In my code, I have asynchronous I/O with I/O Completion Ports, and for the read/write completion callbacks, I get a HANDLE
(that of course can be a socket, file handle, named pipe and so on).
因此,如果此类例程中出现问题,我想检查该错误,但是如何知道它是网络" HANDLE
(一个SOCKET
,所以我应该调用WSAGetLastError()
)还是一个非" -network"HANDLE
(已命名管道,文件等,因此我应该呼叫GetLastError()
)?我为此使用了一个简单的标志,但是它很丑陋且不方便.
So if something is wrong in such routine, I want to check the error, but how to know if its a "network" HANDLE
(a SOCKET
, so I should call WSAGetLastError()
) or a "non-network" HANDLE
(named pipes, files and so on, so I should call GetLastError()
)? I'm using a simple flag for that, but its ugly, and inconvenient.
如果有人可以确认WSAGetLastError()
只是GetLastError()
的别名,我将仅使用后者.
If someone can confirm that WSAGetLastError()
is just an alias for GetLastError()
, I will use only the latter.
似乎是这样:
http://us.generation -nt.com/wsagetlasterror-just-an-alias-getlasterror-help-28256642.html
但是有人可以确认吗? MSDN在这个主题上不是很清楚.
But can someone confirm that? MSDN is not much clear on this topic.
使用GetLastError()
代替WSAGetLastError()
是否安全?我的意思是,如果有人声称Windows95以来WSAGetLastError()
甚至是GetLastError()
的别名,我都可以假定它对于下一版本的Windows都是正确的-但我们不能在假设情况下编写好的代码:)
And would it be safe to use GetLastError()
instead of WSAGetLastError()
? I mean, if WSAGetLastError()
is even an alias of GetLastError()
since Windows95 as someone claim, I could assume that it will be true for the next version of Windows -- but we can't write good code on assuming things :)
推荐答案
如果您对ws2_32.dll进行反向工程,则它只是GetLastError的包装,您会找到它.
It is just a wrapper to GetLastError if you reverse engineering ws2_32.dll, you'll find it.
这篇关于WSAGetLastError()只是GetLastError()的别名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!