sys_socket.in.h 3.2 KB

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