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).
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.
If someone can confirm that WSAGetLastError()
is just an alias for GetLastError()
, I will use only the latter.
It seems so:
http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.networks/2007-08/msg00034.html
http://us.generation-nt.com/wsagetlasterror-just-an-alias-getlasterror-help-28256642.html
But can someone confirm that? MSDN is not much clear on this topic.
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 :)