sockets.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* sockets.h - wrappers for Windows socket functions
  2. Copyright (C) 2008-2011 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. int gl_sockets_cleanup (void);
  23. /* This function is useful it you create a socket using gnulib's
  24. Winsock wrappers but needs to pass on the socket handle to some
  25. other library that only accepts sockets. */
  26. #if WINDOWS_SOCKETS
  27. #include <sys/socket.h>
  28. static inline SOCKET
  29. gl_fd_to_handle (int fd)
  30. {
  31. return _get_osfhandle (fd);
  32. }
  33. #else
  34. #define gl_fd_to_handle(x) (x)
  35. #endif /* WINDOWS_SOCKETS */
  36. #endif /* SOCKETS_H */