A.1 Error Codes

The following is a list of possible error codes returned by the WSAGetLastError() call, along with their explanations. The error numbers are consistently set across all Windows Sockets-compliant implementations.

Windows Sockets code

Berkeley equivalent

Error

Interpretation

WSAEINTR

EINTR

10004

As in standard C

WSAEBADF

EBADF

10009

As in standard C

WSAEACCES

EACCES

10013

As in standard C

WSAEFAULT

EFAULT

10014

As in standard C

WSAEINVAL

EINVAL

10022

As in standard C

WSAEMFILE

EMFILE

10024

As in standard C

WSAEWOULDBLOCK

EWOULDBLOCK

10035

As in BSD

WSAEINPROGRESS

EINPROGRESS

10036

This error is returned if any
Windows Sockets API function is called while a blocking function is in progress.

WSAEALREADY

EALREADY

10037

As in BSD

WSAENOTSOCK

ENOTSOCK

10038

As in BSD

WSAEDESTADDRREQ

EDESTADDRREQ

10039

As in BSD

WSAEMSGSIZE

EMSGSIZE

10040

As in BSD

WSAEPROTOTYPE

EPROTOTYPE

10041

As in BSD

WSAENOPROTOOPT

ENOPROTOOPT

10042

As in BSD

WSAEPROTONOSUPPORT

EPROTONOSUPPORT

10043

As in BSD

WSAESOCKTNOSUPPORT

ESOCKTNOSUPPORT

10044

As in BSD

WSAEOPNOTSUPP

EOPNOTSUPP

10045

As in BSD

WSAEPFNOSUPPORT

EPFNOSUPPORT

10046

As in BSD

WSAEAFNOSUPPORT

EAFNOSUPPORT

10047

As in BSD

WSAEADDRINUSE

EADDRINUSE

10048

As in BSD

WSAEADDRNOTAVAIL

EADDRNOTAVAIL

10049

As in BSD

WSAENETDOWN

ENETDOWN

10050

As in BSD. This error may be reported at any time if the Windows Sockets implementation detects an underlying failure.

WSAENETUNREACH

ENETUNREACH

10051

As in BSD

WSAENETRESET

ENETRESET

10052

As in BSD

WSAECONNABORTED

ECONNABORTED

10053

As in BSD

WSAECONNRESET

ECONNRESET

10054

As in BSD

WSAENOBUFS

ENOBUFS

10055

As in BSD

WSAEISCONN

EISCONN

10056

As in BSD

WSAENOTCONN

ENOTCONN

10057

As in BSD

WSAESHUTDOWN

ESHUTDOWN

10058

As in BSD

WSAETOOMANYREFS

ETOOMANYREFS

10059

As in BSD

WSAETIMEDOUT

ETIMEDOUT

10060

As in BSD

WSAECONNREFUSED

ECONNREFUSED

10061

As in BSD

WSAELOOP

ELOOP

10062

As in BSD

WSAENAMETOOLONG

ENAMETOOLONG

10063

As in BSD

WSAEHOSTDOWN

EHOSTDOWN

10064

As in BSD

WSAEHOSTUNREACH

EHOSTUNREACH

10065

As in BSD

WSASYSNOTREADY

10091

Returned by WSAStartup()
indicating that the network subsystem is unusable.

WSAVERNOTSUPPORTED

10092

Returned by WSAStartup()
indicating that the Windows Sockets
DLL cannot support this app.

WSANOTINITIALISED

10093

Returned by any function except WSAStartup() indicating that a successful WSAStartup() has not yet been performed.

WSAHOST_NOT_FOUND

HOST_NOT_FOUND

11001

As in BSD.

WSATRY_AGAIN

TRY_AGAIN

11002

As in BSD

WSANO_RECOVERY

NO_RECOVERY

11003

As in BSD

WSANO_DATA

NO_DATA

11004

As in BSD


The first set of definitions is present to resolve contentions between standard C error codes which may be defined inconsistently between various C compilers.

The second set of definitions provides Windows Sockets versions of regular Berkeley Sockets error codes.

The third set of definitions consists of extended Windows Sockets-specific error codes.

The fourth set of errors are returned by Windows Sockets getXbyY() and WSAAsyncGetXByY() functions, and correspond to the errors which in Berkeley software would be returned in the h_errno variable. They correspond to various failures which may be returned by the Domain Name Service. If the Windows Sockets implementation does not use the DNS, it will use the most appropriate code. In general, a Windows Sockets application should interpret WSAHOST_NOT_FOUND and WSANO_DATA as indicating that the key (name, address, etc.) was not found,, while WSATRY_AGAIN and WSANO_RECOVERY suggest that the name service itself is non-operational.

The error numbers are derived from the winsock.h header file listed in section A.2.2, and are based on the fact that Windows Sockets error numbers are computed by adding 10000 to the "normal" Berkeley error number.

Note that this table does not include all of the error codes defined in winsock.h. This is because it includes only errors which might reasonably be returned by a Windows Sockets implementation: winsock.h, on the other hand, includes a full set of BSD definitions to ensure compatibility with ported software.