1 /*****************************************************************************
2 * error.c: Network error handling
3 *****************************************************************************
4 * Copyright (C) 2006 Rémi Denis-Courmont
7 * Author : Rémi Denis-Courmont <rem # videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
31 #if defined (WIN32) || defined (UNDER_CE)
38 static const wsaerrmsg_t wsaerrmsg =
40 { WSAEINTR, "Interrupted by signal" },
41 { WSAEACCES, "Access denied" },
42 { WSAEFAULT, "Invalid memory address" },
43 { WSAEINVAL, "Invalid argument" },
44 { WSAEMFILE, "Too many open sockets" },
45 { WSAEWOULDBLOCK, "Would block" },
47 { WSAENOTSOCK, "Non-socket handle specified" },
48 { WSAEDESTADDRREQ, "Missing destination address" },
49 { WSAEMSGSIZE, "Message too big" },
51 { WSAENOPROTOOPT, "Option not supported by protocol" },
52 { WSAEPROTONOSUPPORT, "Protocol not support" },
54 { WSAEOPNOTSUPP, "Operation not supported" },
55 { WSAEPFNOSUPPORT, "Protocol family not supported" },
56 { WSAEAFNOSUPPORT, "Address family not supported" },
57 { WSAEADDRINUSE, "Address already in use" },
58 { WSAEADDRNOTAVAIL, "Address not available" },
59 { WSAENETDOWN, "Network down" },
60 { WSAENETUNREACH, "Network unreachable" },
62 { WSAECONNABORTED, "Connection aborted" },
63 { WSAECONNRESET, "Connection reset by peer" },
64 { WSAENOBUFS, "Not enough memory" },
65 { WSAEISCONN, "Socket already connected" },
66 { WSAENOTCONN, "Connection required first" },
67 { WSAESHUTDOWN, "Connection shutdown" },
68 { WSAETOOMANYREFS, "Too many references" },
69 { WSAETIMEDOUT, "Connection timed out" },
70 { WSAECONNREFUSED, "Connection refused by peer" },
73 { WSAEHOSTDOWN, "Remote host down" },
74 { WSAEHOSTUNREACH, "Remote host unreachable" },
82 { WSASYSNOTREADY, "Network stack not ready" },
83 { WSAVERNOTSUPPORTED, "Network stack version not supported" },
84 { WSANOTINITIALISED, "Network not initialized" },
85 { WSAHOST_NOT_FOUND, "Hostname not found" },
86 { WSATRY_AGAIN, "Temporary hostname error" },
87 { WSANO_RECOVERY, "Non-recoverable hostname error" },
88 /* Winsock2 and QoS error are codes missing,
89 I'm too bored, and they "never" occur. */
94 const char *net_strerror( int value )
96 /* There doesn't seem to be any portable error message generation for
97 * Winsock errors. Some old versions had s_error, but it appears to be
98 * gone, and is not documented.
100 for( const wsaerrmsg_t *e = wsaerrmsg; e.msg != NULL; e++ )
101 if( e.code == value )
104 return "Unknown network stack error";