WSASetLastError

The Windows Sockets WSASetLastError function sets the error code that can be retrieved through the WSAGetLastError function.

void WSASetLastError (
  int iError  
);
 

Parameters

iError
[in] An integer that specifies the error code to be returned by a subsequent WSAGetLastError call.

Remarks

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 reset by calling the function getsockopt with SO_ERROR.

Return Values

None.

Error Codes

WSANOTINITIALISED A successful WSAStartup must occur before using this function.

QuickInfo

  Windows NT: Yes
  Windows: Yes
  Windows CE: Unsupported.
  Header: Declared in winsock2.h.
  Import Library: Link with ws2_32.lib.

See Also

getsockopt, WSAGetLastError