Tizen 2.0 Release
[external/tizen-coreutils.git] / lib / socket_.h
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.
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 _GL_SYS_SOCKET_H
20 #define _GL_SYS_SOCKET_H
21
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.  */
26
27 #if @HAVE_SYS_SOCKET_H@
28
29 /* On many platforms, <sys/socket.h> assumes prior inclusion of
30    <sys/types.h>.  */
31
32 # include <sys/types.h>
33 # include @ABSOLUTE_SYS_SOCKET_H@
34
35 #else
36
37 /* A platform that lacks <sys/socket.h>.
38
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
52    releases. */
53
54
55 # if @HAVE_WINSOCK2_H@
56 #  include <winsock2.h>
57 # endif
58 # if @HAVE_WS2TCPIP_H@
59 #  include <ws2tcpip.h>
60 # endif
61
62 /* For shutdown(). */
63 # if !defined SHUT_RD && defined SD_RECEIVE
64 #  define SHUT_RD SD_RECEIVE
65 # endif
66 # if !defined SHUT_WR && defined SD_SEND
67 #  define SHUT_WR SD_SEND
68 # endif
69 # if !defined SHUT_RDWR && defined SD_BOTH
70 #  define SHUT_RDWR SD_BOTH
71 # endif
72
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
81 # endif
82
83 #endif /* HAVE_SYS_SOCKET_H */
84
85 #endif /* _GL_SYS_SOCKET_H */