Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function sets the error code that can be retrieved through the WSAGetLastErrorfunction.

Syntax

void WSASetLastError(
  int 
iError 
);

Parameters

iError

[in] Integer that specifies the error code to be returned by a subsequent WSAGetLastErrorcall.

Return Value

If no error occurs, no value is returned. If an error occurs, it returns SOCKET_ERROR, and a specific error code can be retrieved by calling the WSAGetLastErrorfunction.

Remarks

This function allows an application to set the error code to be returned by a subsequent WSAGetLastErrorcall 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 WSASetLastErroris different from the error code returned by calling the getsockopt (Windows Sockets)function with SO_ERROR.

Requirements

Header winsock2.h
Library Ws2.lib
Windows Embedded CE Windows CE 2.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also