Update.
[gnutls.git] / lgl / sys_socket_.h
blobe6eb21ff52a4186426d3577aa3e11754899fa2a9
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 Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1, or (at your option)
8 any later version.
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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser 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
25 application. */
27 #if @HAVE_SYS_SOCKET_H@
29 /* On many platforms, <sys/socket.h> assumes prior inclusion of
30 <sys/types.h>. */
32 # include <sys/types.h>
34 # if @HAVE_INCLUDE_NEXT@
35 # include_next <sys/socket.h>
36 # else
37 # include @ABSOLUTE_SYS_SOCKET_H@
38 # endif
40 #else
42 /* A platform that lacks <sys/socket.h>.
44 Currently only MinGW is supported. See the gnulib manual regarding
45 Windows sockets. MinGW has the header files winsock2.h and
46 ws2tcpip.h that declare the sys/socket.h definitions we need. Note
47 that you can influence which definitions you get by setting the
48 WINVER symbol before including these two files. For example,
49 getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that
50 symbol is set indiriectly through WINVER). You can set this by
51 adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your
52 code may not run on older Windows releases then. My Windows 2000
53 box was not able to run the code, for example. The situation is
54 slightly confusing because:
55 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/getaddrinfo_2.asp
56 suggests that getaddrinfo should be available on all Windows
57 releases. */
60 # if @HAVE_WINSOCK2_H@
61 # include <winsock2.h>
62 # endif
63 # if @HAVE_WS2TCPIP_H@
64 # include <ws2tcpip.h>
65 # endif
67 /* For shutdown(). */
68 # if !defined SHUT_RD && defined SD_RECEIVE
69 # define SHUT_RD SD_RECEIVE
70 # endif
71 # if !defined SHUT_WR && defined SD_SEND
72 # define SHUT_WR SD_SEND
73 # endif
74 # if !defined SHUT_RDWR && defined SD_BOTH
75 # define SHUT_RDWR SD_BOTH
76 # endif
78 # if defined _WIN32 || defined __WIN32__
79 # define ENOTSOCK WSAENOTSOCK
80 # define EADDRINUSE WSAEADDRINUSE
81 # define ENETRESET WSAENETRESET
82 # define ECONNABORTED WSAECONNABORTED
83 # define ECONNRESET WSAECONNRESET
84 # define ENOTCONN WSAENOTCONN
85 # define ESHUTDOWN WSAESHUTDOWN
86 # endif
88 #endif /* HAVE_SYS_SOCKET_H */
90 #endif /* _GL_SYS_SOCKET_H */