WSASetLastError function (winsock.h)
The WSASetLastError function sets the error code that can be retrieved through the WSAGetLastError function.
void WSASetLastError( [in] int iError );
Integer that specifies the error code to be returned by a subsequent WSAGetLastError call.
This function generates no return values.
|A successful WSAStartup call must occur before using this function.|
The WSASetLastError function allows an application to set the error code to be returned by a subsequent WSAGetLastError call for the current thread. Note that any subsequent Windows Sockets routine called by the application will override the error code as set by this routine.
The error code set by WSASetLastError is different from the error code returned by calling the function getsockopt with SO_ERROR.
The Windows Sockets error codes used by this function are listed under Windows Sockets Error Codes.
Windows Phone 8: This function is supported for Windows Phone Store apps on Windows Phone 8 and later.
Windows 8.1 and Windows Server 2012 R2: This function is supported for Windows Store apps on Windows 8.1, Windows Server 2012 R2, and later.
|Minimum supported client||Windows 8.1, Windows Vista [desktop apps | UWP apps]|
|Minimum supported server||Windows Server 2003 [desktop apps | UWP apps]|
|Header||winsock.h (include Winsock2.h)|