sockets.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* sockets.h - wrappers for Windows socket functions
  2. Copyright (C) 2008-2014 Free Software Foundation, Inc.
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. /* Written by Simon Josefsson */
  14. #ifndef SOCKETS_H
  15. # define SOCKETS_H 1
  16. #define SOCKETS_1_0 0x100 /* don't use - does not work on Windows XP */
  17. #define SOCKETS_1_1 0x101
  18. #define SOCKETS_2_0 0x200 /* don't use - does not work on Windows XP */
  19. #define SOCKETS_2_1 0x201
  20. #define SOCKETS_2_2 0x202
  21. int gl_sockets_startup (int version)
  22. #if !WINDOWS_SOCKETS
  23. _GL_ATTRIBUTE_CONST
  24. #endif
  25. ;
  26. int gl_sockets_cleanup (void)
  27. #if !WINDOWS_SOCKETS
  28. _GL_ATTRIBUTE_CONST
  29. #endif
  30. ;
  31. /* This function is useful it you create a socket using gnulib's
  32. Winsock wrappers but needs to pass on the socket handle to some
  33. other library that only accepts sockets. */
  34. #if WINDOWS_SOCKETS
  35. #include <sys/socket.h>
  36. #include "msvc-nothrow.h"
  37. static inline SOCKET
  38. gl_fd_to_handle (int fd)
  39. {
  40. return _get_osfhandle (fd);
  41. }
  42. #else
  43. #define gl_fd_to_handle(x) (x)
  44. #endif /* WINDOWS_SOCKETS */
  45. #endif /* SOCKETS_H */