GetLastError和WSAGetLastError的区别解决思路
GetLastError和WSAGetLastError的区别
弱弱的问大家一下,GetLastError和WSAGetLastError的区别是什么呀?
有错误发生时,我用它们两者互换,返回值是一样的。。。
------解决思路----------------------
Notes For Windows Sockets Suppliers
The use of the WSAGetLastError() function to retrieve the last error code, rather than relying on a global error variable (cf. errno), is required in order to provide compatibility with future multi-threaded environments.
Note that in a Win16 environment WSAGetLastError() is used to retrieve only Windows Sockets API errors. In a Win32 environment, WSAGetLastError() will invoke GetLastError(), which is used to retrieve the error status for all Win32 API functions on a per-thread basis. For portability, an application should use WSAGetLastError() immediately after the Windows Sockets API function which failed.
------解决思路----------------------
关于Windows Sockets提供者的说明:
这里使用WSAGetLastError()函数来获得上一次的错误代码,而不是依靠全局错误变量, 是为了提供和将来的多线程环境相兼容.
注意在一个非占先的Windows环境下,WSAGetLastError()只用来获得Windows Sockets API错误.在占先环境下,WSAGetLastError()将调用GetLastError(), 来获得所有在每线程基础上的Win32 API函数的错误状态.为提高可移植性,应用程序应在调用失败后立即使用WSAGetLastError().
------解决思路----------------------
你可以理解为WSAGetlastError是GetLastError的一个子集或者特例。
弱弱的问大家一下,GetLastError和WSAGetLastError的区别是什么呀?
有错误发生时,我用它们两者互换,返回值是一样的。。。
------解决思路----------------------
Notes For Windows Sockets Suppliers
The use of the WSAGetLastError() function to retrieve the last error code, rather than relying on a global error variable (cf. errno), is required in order to provide compatibility with future multi-threaded environments.
Note that in a Win16 environment WSAGetLastError() is used to retrieve only Windows Sockets API errors. In a Win32 environment, WSAGetLastError() will invoke GetLastError(), which is used to retrieve the error status for all Win32 API functions on a per-thread basis. For portability, an application should use WSAGetLastError() immediately after the Windows Sockets API function which failed.
------解决思路----------------------
关于Windows Sockets提供者的说明:
这里使用WSAGetLastError()函数来获得上一次的错误代码,而不是依靠全局错误变量, 是为了提供和将来的多线程环境相兼容.
注意在一个非占先的Windows环境下,WSAGetLastError()只用来获得Windows Sockets API错误.在占先环境下,WSAGetLastError()将调用GetLastError(), 来获得所有在每线程基础上的Win32 API函数的错误状态.为提高可移植性,应用程序应在调用失败后立即使用WSAGetLastError().
------解决思路----------------------
你可以理解为WSAGetlastError是GetLastError的一个子集或者特例。