1 /* Provide a sys/socket header file for systems lacking it (read: MinGW).
2 Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
3 Written by Simon Josefsson.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 #ifndef _GL_SYS_SOCKET_H
20 #define _GL_SYS_SOCKET_H
22 /* This file is supposed to be used on platforms that lack <sys/socket.h>
23 and on platforms where <sys/socket.h> cannot be included standalone.
24 It is intended to provide definitions and prototypes needed by an
27 #if @HAVE_SYS_SOCKET_H@
29 /* On many platforms, <sys/socket.h> assumes prior inclusion of
32 # include <sys/types.h>
33 # include @ABSOLUTE_SYS_SOCKET_H@
37 /* A platform that lacks <sys/socket.h>.
39 Currently only MinGW is supported. See the gnulib manual regarding
40 Windows sockets. MinGW has the header files winsock2.h and
41 ws2tcpip.h that declare the sys/socket.h definitions we need. Note
42 that you can influence which definitions you get by setting the
43 WINVER symbol before including these two files. For example,
44 getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that
45 symbol is set indiriectly through WINVER). You can set this by
46 adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your
47 code may not run on older Windows releases then. My Windows 2000
48 box was not able to run the code, for example. The situation is
49 slightly confusing because:
50 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/getaddrinfo_2.asp
51 suggests that getaddrinfo should be available on all Windows
55 # if @HAVE_WINSOCK2_H@
56 # include <winsock2.h>
58 # if @HAVE_WS2TCPIP_H@
59 # include <ws2tcpip.h>
63 # if !defined SHUT_RD && defined SD_RECEIVE
64 # define SHUT_RD SD_RECEIVE
66 # if !defined SHUT_WR && defined SD_SEND
67 # define SHUT_WR SD_SEND
69 # if !defined SHUT_RDWR && defined SD_BOTH
70 # define SHUT_RDWR SD_BOTH
73 # if defined _WIN32 || defined __WIN32__
74 # define ENOTSOCK WSAENOTSOCK
75 # define EADDRINUSE WSAEADDRINUSE
76 # define ENETRESET WSAENETRESET
77 # define ECONNABORTED WSAECONNABORTED
78 # define ECONNRESET WSAECONNRESET
79 # define ENOTCONN WSAENOTCONN
80 # define ESHUTDOWN WSAESHUTDOWN
83 #endif /* HAVE_SYS_SOCKET_H */
85 #endif /* _GL_SYS_SOCKET_H */