diff options
Diffstat (limited to 'gl/socket_.h')
-rw-r--r-- | gl/socket_.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/gl/socket_.h b/gl/socket_.h new file mode 100644 index 0000000..8b28b5e --- /dev/null +++ b/gl/socket_.h | |||
@@ -0,0 +1,70 @@ | |||
1 | /* Provide a sys/socket header file for systems lacking it (read: MinGW). | ||
2 | Copyright (C) 2005, 2006 Free Software Foundation, Inc. | ||
3 | Written by Simon Josefsson. | ||
4 | |||
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) | ||
8 | any later version. | ||
9 | |||
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. | ||
14 | |||
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. */ | ||
18 | |||
19 | #ifndef _SYS_SOCKET_H | ||
20 | #define _SYS_SOCKET_H | ||
21 | |||
22 | /* This file is supposed to be used on platforms that lack | ||
23 | sys/socket.h. It is intended to provide definitions and prototypes | ||
24 | needed by an application. | ||
25 | |||
26 | Currently only MinGW is supported. See the gnulib manual regarding | ||
27 | Windows sockets. MinGW has the header files winsock2.h and | ||
28 | ws2tcpip.h that declare the sys/socket.h definitions we need. Note | ||
29 | that you can influence which definitions you get by setting the | ||
30 | WINVER symbol before including these two files. For example, | ||
31 | getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that | ||
32 | symbol is set indiriectly through WINVER). You can set this by | ||
33 | adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your | ||
34 | code may not run on older Windows releases then. My Windows 2000 | ||
35 | box was not able to run the code, for example. The situation is | ||
36 | slightly confusing because: | ||
37 | http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/getaddrinfo_2.asp | ||
38 | suggests that getaddrinfo should be available on all Windows | ||
39 | releases. */ | ||
40 | |||
41 | |||
42 | #if HAVE_WINSOCK2_H | ||
43 | # include <winsock2.h> | ||
44 | #endif | ||
45 | #if HAVE_WS2TCPIP_H | ||
46 | # include <ws2tcpip.h> | ||
47 | #endif | ||
48 | |||
49 | /* For shutdown(). */ | ||
50 | #if !defined SHUT_RD && defined SD_RECEIVE | ||
51 | # define SHUT_RD SD_RECEIVE | ||
52 | #endif | ||
53 | #if !defined SHUT_WR && defined SD_SEND | ||
54 | # define SHUT_WR SD_SEND | ||
55 | #endif | ||
56 | #if !defined SHUT_RDWR && defined SD_BOTH | ||
57 | # define SHUT_RDWR SD_BOTH | ||
58 | #endif | ||
59 | |||
60 | #if defined _WIN32 || defined __WIN32__ | ||
61 | # define ENOTSOCK WSAENOTSOCK | ||
62 | # define EADDRINUSE WSAEADDRINUSE | ||
63 | # define ENETRESET WSAENETRESET | ||
64 | # define ECONNABORTED WSAECONNABORTED | ||
65 | # define ECONNRESET WSAECONNRESET | ||
66 | # define ENOTCONN WSAENOTCONN | ||
67 | # define ESHUTDOWN WSAESHUTDOWN | ||
68 | #endif | ||
69 | |||
70 | #endif /* _SYS_SOCKET_H */ | ||