Winsock Error Codes
This section provides a comprehensive list of error codes that can be returned by Winsock functions. Understanding these codes is crucial for diagnosing and resolving network communication issues.
Common Winsock Errors
Error Code | Symbolic Name | Description |
---|---|---|
10001 | WSAHOST_NOT_FOUND |
Authoritative answer: Host not found. |
10002 | WSATRY_AGAIN |
Non-authoritative answer: Host not found or server failed. |
10003 | WSANO_RECOVERY |
Non-recoverable error: Requested name is valid but no data of the requested type was found. |
10004 | WSANO_DATA |
Non-recoverable error: Requested name is valid but no data of the requested type was found. |
10005 | WSAEINTR |
A blocking Winsock call was interrupted by a call to WSACancelAsyncRequest. |
10006 | WSAEINPROGRESS |
A blocking operation is currently in progress. |
10007 | WSAEALREADY |
An asynchronous operation is already in progress. |
10008 | WSAENOTSOCK |
An operation was attempted on something that is not a socket. |
10009 | WSAEDESTADDRREQ |
Destination address required. |
10010 | WSAEMSGSZ |
Message too long. |
10011 | WSAEPFNOSUPPORT |
Protocol family not supported. |
10012 | WSAEPROTONOSUPPORT |
Protocol not supported. |
10013 | WSAESOCKTNOSUPPORT |
Socket type not supported. |
10014 | WSAEOPNOTSUPP |
Operation not supported. |
10015 | WSAEPOTSUPP |
Policy violation. |
10016 | WSAEADDRINUSE |
Address already in use. |
10017 | WSAEADDRNOTAVAIL |
Cannot assign requested address. |
10018 | WSAENETDOWN |
Network is down. |
10019 | WSAENETUNREACH |
Network is unreachable. |
10020 | WSAENETRESET |
Network dropped connection because of reset. |
10021 | WSAECONNABORTED |
Software caused connection abort. |
10022 | WSAECONNRESET |
Connection reset by peer. |
10023 | WSAENOBUFS |
No buffer space available. |
10024 | WSAEISCONN |
Socket is already connected. |
10025 | WSAENOTCONN |
Socket is not connected. |
10026 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10027 | WSAETOOMANYREFS |
Too many references. |
10028 | WSAETIMEDOUT |
Connection timed out. |
10029 | WSAECONNREFUSED |
Connection refused. |
10030 | WSAELOOP |
Too many levels of symbolic link. |
10031 | WSAENAMETOOLONG |
Filename or pathname too long. |
10032 | WSAEHOSTDOWN |
Host is down. |
10033 | WSAEWOULDBLOCK |
Operation would block. |
10034 | WSAENOTEMPTY |
Directory not empty. |
10035 | WSAENOMOREFILES |
No more files. |
10036 | WSAEISDIR |
Is a directory. |
10037 | WSAENOTDIR |
Not a directory. |
10038 | WSAEINVAL |
Invalid argument. |
10039 | WSAENFILE |
Too many open files. |
10040 | WSAEISNAM |
Is a named pipe. |
10041 | WSAENOTTY |
Not a typewriter. |
10042 | WSAESPIPE |
Is a pipe. |
10043 | WSAEACCES |
Permission denied. |
10044 | WSAEDQUOT |
Disk quota exceeded. |
10045 | WSAEDQUOT |
No space left on device. |
10046 | WSAESTALE |
Stale file handle reference. |
10047 | WSAENOMSG |
No message available on the requested facility to receive. |
10048 | WSAEREMOTE |
Object is remote. |
10049 | WSAENOLCK |
No record locks available. |
10050 | WSAENOMSG |
No message available. |
10051 | WSAERANGE |
Out of range. |
10052 | WSAENOTSOCK |
Socket operation on non-socket. |
10053 | WSAEINPROGRESS |
Operation now in progress. |
10054 | WSAEALREADY |
Operation already in progress. |
10055 | WSAEWOULDBLOCK |
Operation would block. |
10056 | WSAENOTSOCK |
Socket is already connected. |
10057 | WSAENOTCONN |
Socket is not connected. |
10058 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10059 | WSAETOOMANYREFS |
Too many references. |
10060 | WSAETIMEDOUT |
Connection timed out. |
10061 | WSAECONNREFUSED |
Connection refused. |
10062 | WSAELOOP |
Too many levels of symbolic link. |
10063 | WSAENAMETOOLONG |
Filename or pathname too long. |
10064 | WSAEHOSTDOWN |
Host is down. |
10065 | WSAENETUNREACH |
Network is unreachable. |
10066 | WSAENETRESET |
Network dropped connection because of reset. |
10067 | WSAECONNABORTED |
Software caused connection abort. |
10068 | WSAECONNRESET |
Connection reset by peer. |
10069 | WSAENOBUFS |
No buffer space available. |
10070 | WSAEISCONN |
Socket is already connected. |
10071 | WSAENOTCONN |
Socket is not connected. |
10072 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10073 | WSAETOOMANYREFS |
Too many references. |
10074 | WSAETIMEDOUT |
Connection timed out. |
10075 | WSAECONNREFUSED |
Connection refused. |
10076 | WSAELOOP |
Too many levels of symbolic link. |
10077 | WSAENAMETOOLONG |
Filename or pathname too long. |
10078 | WSAEHOSTDOWN |
Host is down. |
10079 | WSAENETUNREACH |
Network is unreachable. |
10080 | WSAENETRESET |
Network dropped connection because of reset. |
10081 | WSAECONNABORTED |
Software caused connection abort. |
10082 | WSAECONNRESET |
Connection reset by peer. |
10083 | WSAENOBUFS |
No buffer space available. |
10084 | WSAEISCONN |
Socket is already connected. |
10085 | WSAENOTCONN |
Socket is not connected. |
10086 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10087 | WSAETOOMANYREFS |
Too many references. |
10088 | WSAETIMEDOUT |
Connection timed out. |
10089 | WSAECONNREFUSED |
Connection refused. |
10090 | WSAELOOP |
Too many levels of symbolic link. |
10091 | WSAENAMETOOLONG |
Filename or pathname too long. |
10092 | WSAEHOSTDOWN |
Host is down. |
10093 | WSAENETUNREACH |
Network is unreachable. |
10094 | WSAENETRESET |
Network dropped connection because of reset. |
10095 | WSAECONNABORTED |
Software caused connection abort. |
10096 | WSAECONNRESET |
Connection reset by peer. |
10097 | WSAENOBUFS |
No buffer space available. |
10098 | WSAEISCONN |
Socket is already connected. |
10099 | WSAENOTCONN |
Socket is not connected. |
10100 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10101 | WSAETOOMANYREFS |
Too many references. |
10102 | WSAETIMEDOUT |
Connection timed out. |
10103 | WSAECONNREFUSED |
Connection refused. |
10104 | WSAELOOP |
Too many levels of symbolic link. |
10105 | WSAENAMETOOLONG |
Filename or pathname too long. |
10106 | WSAEHOSTDOWN |
Host is down. |
10107 | WSAENETUNREACH |
Network is unreachable. |
10108 | WSAENETRESET |
Network dropped connection because of reset. |
10109 | WSAECONNABORTED |
Software caused connection abort. |
10110 | WSAECONNRESET |
Connection reset by peer. |
10111 | WSAENOBUFS |
No buffer space available. |
10112 | WSAEISCONN |
Socket is already connected. |
10113 | WSAENOTCONN |
Socket is not connected. |
10114 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10115 | WSAETOOMANYREFS |
Too many references. |
10116 | WSAETIMEDOUT |
Connection timed out. |
10117 | WSAECONNREFUSED |
Connection refused. |
10118 | WSAELOOP |
Too many levels of symbolic link. |
10119 | WSAENAMETOOLONG |
Filename or pathname too long. |
10120 | WSAEHOSTDOWN |
Host is down. |
10121 | WSAENETUNREACH |
Network is unreachable. |
10122 | WSAENETRESET |
Network dropped connection because of reset. |
10123 | WSAECONNABORTED |
Software caused connection abort. |
10124 | WSAECONNRESET |
Connection reset by peer. |
10125 | WSAENOBUFS |
No buffer space available. |
10126 | WSAEISCONN |
Socket is already connected. |
10127 | WSAENOTCONN |
Socket is not connected. |
10128 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10129 | WSAETOOMANYREFS |
Too many references. |
10130 | WSAETIMEDOUT |
Connection timed out. |
10131 | WSAECONNREFUSED |
Connection refused. |
10132 | WSAELOOP |
Too many levels of symbolic link. |
10133 | WSAENAMETOOLONG |
Filename or pathname too long. |
10134 | WSAEHOSTDOWN |
Host is down. |
10135 | WSAENETUNREACH |
Network is unreachable. |
10136 | WSAENETRESET |
Network dropped connection because of reset. |
10137 | WSAECONNABORTED |
Software caused connection abort. |
10138 | WSAECONNRESET |
Connection reset by peer. |
10139 | WSAENOBUFS |
No buffer space available. |
10140 | WSAEISCONN |
Socket is already connected. |
10141 | WSAENOTCONN |
Socket is not connected. |
10142 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10143 | WSAETOOMANYREFS |
Too many references. |
10144 | WSAETIMEDOUT |
Connection timed out. |
10145 | WSAECONNREFUSED |
Connection refused. |
10146 | WSAELOOP |
Too many levels of symbolic link. |
10147 | WSAENAMETOOLONG |
Filename or pathname too long. |
10148 | WSAEHOSTDOWN |
Host is down. |
10149 | WSAENETUNREACH |
Network is unreachable. |
10150 | WSAENETRESET |
Network dropped connection because of reset. |
10151 | WSAECONNABORTED |
Software caused connection abort. |
10152 | WSAECONNRESET |
Connection reset by peer. |
10153 | WSAENOBUFS |
No buffer space available. |
10154 | WSAEISCONN |
Socket is already connected. |
10155 | WSAENOTCONN |
Socket is not connected. |
10156 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10157 | WSAETOOMANYREFS |
Too many references. |
10158 | WSAETIMEDOUT |
Connection timed out. |
10159 | WSAECONNREFUSED |
Connection refused. |
10160 | WSAELOOP |
Too many levels of symbolic link. |
10161 | WSAENAMETOOLONG |
Filename or pathname too long. |
10162 | WSAEHOSTDOWN |
Host is down. |
10163 | WSAENETUNREACH |
Network is unreachable. |
10164 | WSAENETRESET |
Network dropped connection because of reset. |
10165 | WSAECONNABORTED |
Software caused connection abort. |
10166 | WSAECONNRESET |
Connection reset by peer. |
10167 | WSAENOBUFS |
No buffer space available. |
10168 | WSAEISCONN |
Socket is already connected. |
10169 | WSAENOTCONN |
Socket is not connected. |
10170 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10171 | WSAETOOMANYREFS |
Too many references. |
10172 | WSAETIMEDOUT |
Connection timed out. |
10173 | WSAECONNREFUSED |
Connection refused. |
10174 | WSAELOOP |
Too many levels of symbolic link. |
10175 | WSAENAMETOOLONG |
Filename or pathname too long. |
10176 | WSAEHOSTDOWN |
Host is down. |
10177 | WSAENETUNREACH |
Network is unreachable. |
10178 | WSAENETRESET |
Network dropped connection because of reset. |
10179 | WSAECONNABORTED |
Software caused connection abort. |
10180 | WSAECONNRESET |
Connection reset by peer. |
10181 | WSAENOBUFS |
No buffer space available. |
10182 | WSAEISCONN |
Socket is already connected. |
10183 | WSAENOTCONN |
Socket is not connected. |
10184 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10185 | WSAETOOMANYREFS |
Too many references. |
10186 | WSAETIMEDOUT |
Connection timed out. |
10187 | WSAECONNREFUSED |
Connection refused. |
10188 | WSAELOOP |
Too many levels of symbolic link. |
10189 | WSAENAMETOOLONG |
Filename or pathname too long. |
10190 | WSAEHOSTDOWN |
Host is down. |
10191 | WSAENETUNREACH |
Network is unreachable. |
10192 | WSAENETRESET |
Network dropped connection because of reset. |
10193 | WSAECONNABORTED |
Software caused connection abort. |
10194 | WSAECONNRESET |
Connection reset by peer. |
10195 | WSAENOBUFS |
No buffer space available. |
10196 | WSAEISCONN |
Socket is already connected. |
10197 | WSAENOTCONN |
Socket is not connected. |
10198 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10199 | WSAETOOMANYREFS |
Too many references. |
10200 | WSAETIMEDOUT |
Connection timed out. |
10201 | WSAECONNREFUSED |
Connection refused. |
10202 | WSAELOOP |
Too many levels of symbolic link. |
10203 | WSAENAMETOOLONG |
Filename or pathname too long. |
10204 | WSAEHOSTDOWN |
Host is down. |
10205 | WSAENETUNREACH |
Network is unreachable. |
10206 | WSAENETRESET |
Network dropped connection because of reset. |
10207 | WSAECONNABORTED |
Software caused connection abort. |
10208 | WSAECONNRESET |
Connection reset by peer. |
10209 | WSAENOBUFS |
No buffer space available. |
10210 | WSAEISCONN |
Socket is already connected. |
10211 | WSAENOTCONN |
Socket is not connected. |
10212 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10213 | WSAETOOMANYREFS |
Too many references. |
10214 | WSAETIMEDOUT |
Connection timed out. |
10215 | WSAECONNREFUSED |
Connection refused. |
10216 | WSAELOOP |
Too many levels of symbolic link. |
10217 | WSAENAMETOOLONG |
Filename or pathname too long. |
10218 | WSAEHOSTDOWN |
Host is down. |
10219 | WSAENETUNREACH |
Network is unreachable. |
10220 | WSAENETRESET |
Network dropped connection because of reset. |
10221 | WSAECONNABORTED |
Software caused connection abort. |
10222 | WSAECONNRESET |
Connection reset by peer. |
10223 | WSAENOBUFS |
No buffer space available. |
10224 | WSAEISCONN |
Socket is already connected. |
10225 | WSAENOTCONN |
Socket is not connected. |
10226 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10227 | WSAETOOMANYREFS |
Too many references. |
10228 | WSAETIMEDOUT |
Connection timed out. |
10229 | WSAECONNREFUSED |
Connection refused. |
10230 | WSAELOOP |
Too many levels of symbolic link. |
10231 | WSAENAMETOOLONG |
Filename or pathname too long. |
10232 | WSAEHOSTDOWN |
Host is down. |
10233 | WSAENETUNREACH |
Network is unreachable. |
10234 | WSAENETRESET |
Network dropped connection because of reset. |
10235 | WSAECONNABORTED |
Software caused connection abort. |
10236 | WSAECONNRESET |
Connection reset by peer. |
10237 | WSAENOBUFS |
No buffer space available. |
10238 | WSAEISCONN |
Socket is already connected. |
10239 | WSAENOTCONN |
Socket is not connected. |
10240 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10241 | WSAETOOMANYREFS |
Too many references. |
10242 | WSAETIMEDOUT |
Connection timed out. |
10243 | WSAECONNREFUSED |
Connection refused. |
10244 | WSAELOOP |
Too many levels of symbolic link. |
10245 | WSAENAMETOOLONG |
Filename or pathname too long. |
10246 | WSAEHOSTDOWN |
Host is down. |
10247 | WSAENETUNREACH |
Network is unreachable. |
10248 | WSAENETRESET |
Network dropped connection because of reset. |
10249 | WSAECONNABORTED |
Software caused connection abort. |
10250 | WSAECONNRESET |
Connection reset by peer. |
10251 | WSAENOBUFS |
No buffer space available. |
10252 | WSAEISCONN |
Socket is already connected. |
10253 | WSAENOTCONN |
Socket is not connected. |
10254 | WSAESHUTDOWN |
Cannot send after socket shutdown. |
10255 | WSAEINVAL |
Invalid argument. |
Interpreting Winsock Errors
Winsock error codes are typically returned by functions as the return value of the function. For example, a function might return SOCKET_ERROR, and you would then call WSAGetLastError() to retrieve the specific error code.
The error codes are typically in the range of 10001 to 11000. Some common error codes include:
- WSAEINTR (10004): An operation was interrupted.
- WSAECONNRESET (10054): The connection was reset by the remote host.
- WSAETIMEDOUT (10060): The connection attempt timed out.
- WSAECONNREFUSED (10061): The connection was refused by the remote host.
It's essential to consult the full list for specific troubleshooting.
Getting the Last Error
To retrieve the most recent error code for a Winsock function, you typically use the WSAGetLastError() function. This function should be called immediately after a Winsock function returns a failure code (often SOCKET_ERROR).
int result = send(mySocket, buffer, bytesToSend, 0);
if (result == SOCKET_ERROR) {
int errorCode = WSAGetLastError();
// Handle the error based on errorCode
switch(errorCode) {
case WSAECONNRESET:
// Connection reset by peer
break;
// ... other error cases
default:
// Unknown error
break;
}
}