1 /* HSOCKET.H (c) Copyright Roger Bowler, 2005-2009 */ 2 /* Equates for socket functions */ 3 4 /* This header file contains equates for the socket functions */ 5 /* and constants whose values differ between Unix and Winsock */ 6 7 #if !defined(_HSOCKET_H) 8 #define _HSOCKET_H 9 10 #ifndef _HSOCKET_C_ 11 #ifndef _HUTIL_DLL_ 12 #define HSOCK_DLL_IMPORT DLL_IMPORT 13 #else 14 #define HSOCK_DLL_IMPORT extern 15 #endif 16 #else 17 #define HSOCK_DLL_IMPORT DLL_EXPORT 18 #endif 19 20 /*-------------------------------------------------------------------*/ 21 /* Socket related constants related to 'shutdown' API call */ 22 /*-------------------------------------------------------------------*/ 23 24 #ifdef _MSVC_ 25 26 /* Map SUS\*nix constants to Windows socket equivalents */ 27 28 #define SHUT_RD SD_RECEIVE 29 #define SHUT_WR SD_SEND 30 #define SHUT_RDWR SD_BOTH 31 32 #endif 33 34 #if defined(_WINSOCKAPI_) 35 36 /*-------------------------------------------------------------------*/ 37 /* Equates for systems which use the Winsock API */ 38 /*-------------------------------------------------------------------*/ 39 40 #define get_HSO_errno() ((int)WSAGetLastError()) 41 #define set_HSO_errno(e) (WSASetLastError(e)) 42 43 #define HSO_errno get_HSO_errno() 44 45 #define HSO_EINTR WSAEINTR 46 #define HSO_EBADF WSAEBADF 47 #define HSO_EACCES WSAEACCES 48 #define HSO_EFAULT WSAEFAULT 49 #define HSO_EINVAL WSAEINVAL 50 #define HSO_EMFILE WSAEMFILE 51 #define HSO_EWOULDBLOCK WSAEWOULDBLOCK 52 #define HSO_EINPROGRESS WSAEINPROGRESS 53 #define HSO_EALREADY WSAEALREADY 54 #define HSO_ENOTSOCK WSAENOTSOCK 55 #define HSO_EDESTADDRREQ WSAEDESTADDRREQ 56 #define HSO_EMSGSIZE WSAEMSGSIZE 57 #define HSO_EPROTOTYPE WSAEPROTOTYPE 58 #define HSO_ENOPROTOOPT WSAENOPROTOOPT 59 #define HSO_EPROTONOSUPPORT WSAEPROTONOSUPPORT 60 #define HSO_ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT 61 #define HSO_EOPNOTSUPP WSAEOPNOTSUPP 62 #define HSO_EPFNOSUPPORT WSAEPFNOSUPPORT 63 #define HSO_EAFNOSUPPORT WSAEAFNOSUPPORT 64 #define HSO_EADDRINUSE WSAEADDRINUSE 65 #define HSO_EADDRNOTAVAIL WSAEADDRNOTAVAIL 66 #define HSO_ENETDOWN WSAENETDOWN 67 #define HSO_ENETUNREACH WSAENETUNREACH 68 #define HSO_ENETRESET WSAENETRESET 69 #define HSO_ECONNABORTED WSAECONNABORTED 70 #define HSO_ECONNRESET WSAECONNRESET 71 #define HSO_ENOBUFS WSAENOBUFS 72 #define HSO_EISCONN WSAEISCONN 73 #define HSO_ENOTCONN WSAENOTCONN 74 #define HSO_ESHUTDOWN WSAESHUTDOWN 75 #define HSO_ETOOMANYREFS WSAETOOMANYREFS 76 #define HSO_ETIMEDOUT WSAETIMEDOUT 77 #define HSO_ECONNREFUSED WSAECONNREFUSED 78 #define HSO_ELOOP WSAELOOP 79 #define HSO_ENAMETOOLONG WSAENAMETOOLONG 80 #define HSO_EHOSTDOWN WSAEHOSTDOWN 81 #define HSO_EHOSTUNREACH WSAEHOSTUNREACH 82 #define HSO_ENOTEMPTY WSAENOTEMPTY 83 #define HSO_EPROCLIM WSAEPROCLIM 84 #define HSO_EUSERS WSAEUSERS 85 #define HSO_EDQUOT WSAEDQUOT 86 #define HSO_ESTALE WSAESTALE 87 #define HSO_EREMOTE WSAEREMOTE 88 89 #else 90 91 /*-------------------------------------------------------------------*/ 92 /* Equates for systems which use the Berkeley sockets API */ 93 /*-------------------------------------------------------------------*/ 94 95 #define get_HSO_errno() (errno) 96 #define set_HSO_errno(e) (errno=(e)) 97 98 #define HSO_errno get_HSO_errno() 99 100 #define HSO_EINTR EINTR 101 #define HSO_EBADF EBADF 102 #define HSO_EACCES EACCES 103 #define HSO_EFAULT EFAULT 104 #define HSO_EINVAL EINVAL 105 #define HSO_EMFILE EMFILE 106 #define HSO_EWOULDBLOCK EWOULDBLOCK 107 #define HSO_EINPROGRESS EINPROGRESS 108 #define HSO_EALREADY EALREADY 109 #define HSO_ENOTSOCK ENOTSOCK 110 #define HSO_EDESTADDRREQ EDESTADDRREQ 111 #define HSO_EMSGSIZE EMSGSIZE 112 #define HSO_EPROTOTYPE EPROTOTYPE 113 #define HSO_ENOPROTOOPT ENOPROTOOPT 114 #define HSO_EPROTONOSUPPORT EPROTONOSUPPORT 115 #define HSO_ESOCKTNOSUPPORT ESOCKTNOSUPPORT 116 #define HSO_EOPNOTSUPP EOPNOTSUPP 117 #define HSO_EPFNOSUPPORT EPFNOSUPPORT 118 #define HSO_EAFNOSUPPORT EAFNOSUPPORT 119 #define HSO_EADDRINUSE EADDRINUSE 120 #define HSO_EADDRNOTAVAIL EADDRNOTAVAIL 121 #define HSO_ENETDOWN ENETDOWN 122 #define HSO_ENETUNREACH ENETUNREACH 123 #define HSO_ENETRESET ENETRESET 124 #define HSO_ECONNABORTED ECONNABORTED 125 #define HSO_ECONNRESET ECONNRESET 126 #define HSO_ENOBUFS ENOBUFS 127 #define HSO_EISCONN EISCONN 128 #define HSO_ENOTCONN ENOTCONN 129 #define HSO_ESHUTDOWN ESHUTDOWN 130 #define HSO_ETOOMANYREFS ETOOMANYREFS 131 #define HSO_ETIMEDOUT ETIMEDOUT 132 #define HSO_ECONNREFUSED ECONNREFUSED 133 #define HSO_ELOOP ELOOP 134 #define HSO_ENAMETOOLONG ENAMETOOLONG 135 #define HSO_EHOSTDOWN EHOSTDOWN 136 #define HSO_EHOSTUNREACH EHOSTUNREACH 137 #define HSO_ENOTEMPTY ENOTEMPTY 138 #define HSO_EPROCLIM EPROCLIM 139 #define HSO_EUSERS EUSERS 140 #define HSO_EDQUOT EDQUOT 141 #define HSO_ESTALE ESTALE 142 #define HSO_EREMOTE EREMOTE 143 144 #endif 145 146 /*-------------------------------------------------------------------*/ 147 /* Local function definitions */ 148 /*-------------------------------------------------------------------*/ 149 150 HSOCK_DLL_IMPORT int read_socket(int fd, void *ptr, int nbytes); 151 HSOCK_DLL_IMPORT int write_socket(int fd, const void *ptr, int nbytes); 152 153 #endif /*!defined(_HSOCKET_H)*/ 154