Is WSAGetLastError() just an alias for GetLastError()?

前端 未结 2 1913
日久生厌
日久生厌 2021-01-11 15:47

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

相关标签:
2条回答
  • 2021-01-11 16:19

    It is just a wrapper to GetLastError if you reverse engineering ws2_32.dll, you'll find it.

    0 讨论(0)
  • 2021-01-11 16:22

    Reason behind having two similar functions: http://blogs.msdn.com/b/oldnewthing/archive/2005/09/08/462402.aspx

    Why does the function WSASetLastError exist when there is already the perfectly good function SetLastError?

    Actually, you know the answer too, if you sit down and think about it.

    Winsock was originally developed to run on both 16-bit Windows and 32-bit Windows. Notice how the classic Winsock functions are based on window messages for asynchronous notifications. In the 16-bit world, there was no SetLastError function. Therefore, Winsock had to provide its own version for the 16-bit implementation. And since source code compatibility is important, there was a 32-bit version as well. Of course, the 32-bit version looks kind of stupid in retrospect if you aren't aware of the 16-bit version.

    0 讨论(0)
提交回复
热议问题