NetCommon.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /**********
  2. This library is free software; you can redistribute it and/or modify it under
  3. the terms of the GNU Lesser General Public License as published by the
  4. Free Software Foundation; either version 3 of the License, or (at your
  5. option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
  6. This library is distributed in the hope that it will be useful, but WITHOUT
  7. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
  9. more details.
  10. You should have received a copy of the GNU Lesser General Public License
  11. along with this library; if not, write to the Free Software Foundation, Inc.,
  12. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  13. **********/
  14. /* "groupsock" interface
  15. * Copyright (c) 1996-2020 Live Networks, Inc. All rights reserved.
  16. * Common include files, typically used for networking
  17. */
  18. #ifndef _NET_COMMON_H
  19. #define _NET_COMMON_H
  20. #if defined(__WIN32__) || defined(_WIN32) || defined(_WIN32_WCE)
  21. /* Windows */
  22. #if defined(WINNT) || defined(_WINNT) || defined(__BORLANDC__) || defined(__MINGW32__) || defined(_WIN32_WCE) || defined (_MSC_VER)
  23. #define _MSWSOCK_
  24. #include <winsock2.h>
  25. #include <ws2tcpip.h>
  26. #endif
  27. #include <windows.h>
  28. #include <errno.h>
  29. #include <string.h>
  30. #define closeSocket closesocket
  31. #ifdef EWOULDBLOCK
  32. #undef EWOULDBLOCK
  33. #endif
  34. #ifdef EINPROGRESS
  35. #undef EINPROGRESS
  36. #endif
  37. #ifdef EAGAIN
  38. #undef EAGAIN
  39. #endif
  40. #ifdef EINTR
  41. #undef EINTR
  42. #endif
  43. #define EWOULDBLOCK WSAEWOULDBLOCK
  44. #define EINPROGRESS WSAEWOULDBLOCK
  45. #define EAGAIN WSAEWOULDBLOCK
  46. #define EINTR WSAEINTR
  47. #if defined(_WIN32_WCE)
  48. #define NO_STRSTREAM 1
  49. #endif
  50. /* Definitions of size-specific types: */
  51. typedef __int64 int64_t;
  52. typedef unsigned __int64 u_int64_t;
  53. typedef int int32_t;
  54. typedef unsigned u_int32_t;
  55. typedef short int16_t;
  56. typedef unsigned short u_int16_t;
  57. typedef unsigned char u_int8_t;
  58. // For "uintptr_t" and "intptr_t", we assume that if they're not already defined, then this must be
  59. // an old, 32-bit version of Windows:
  60. #if !defined(_MSC_STDINT_H_) && !defined(_UINTPTR_T_DEFINED) && !defined(_UINTPTR_T_DECLARED) && !defined(_UINTPTR_T)
  61. typedef unsigned uintptr_t;
  62. #endif
  63. #if !defined(_MSC_STDINT_H_) && !defined(_INTPTR_T_DEFINED) && !defined(_INTPTR_T_DECLARED) && !defined(_INTPTR_T)
  64. typedef int intptr_t;
  65. #endif
  66. #elif defined(VXWORKS)
  67. /* VxWorks */
  68. #include <time.h>
  69. #include <timers.h>
  70. #include <sys/times.h>
  71. #include <sockLib.h>
  72. #include <hostLib.h>
  73. #include <resolvLib.h>
  74. #include <ioLib.h>
  75. typedef unsigned int u_int32_t;
  76. typedef unsigned short u_int16_t;
  77. typedef unsigned char u_int8_t;
  78. #else
  79. /* Unix */
  80. #include <sys/types.h>
  81. #include <sys/socket.h>
  82. #include <sys/time.h>
  83. #include <netinet/in.h>
  84. #include <arpa/inet.h>
  85. #include <netdb.h>
  86. #include <unistd.h>
  87. #include <string.h>
  88. #include <stdlib.h>
  89. #include <errno.h>
  90. #include <strings.h>
  91. #include <ctype.h>
  92. #include <stdint.h>
  93. #if defined(_QNX4)
  94. #include <sys/select.h>
  95. #include <unix.h>
  96. #endif
  97. #define closeSocket close
  98. #ifdef SOLARIS
  99. #define u_int64_t uint64_t
  100. #define u_int32_t uint32_t
  101. #define u_int16_t uint16_t
  102. #define u_int8_t uint8_t
  103. #endif
  104. #endif
  105. #ifndef SOCKLEN_T
  106. #define SOCKLEN_T int
  107. #endif
  108. #endif