1 /**************************************************************** 2 * 3 * TCPIP.H - Portable TCP/IP header file 4 * 5 * TCP/IP on OS/2 is an add-on and thus is not fully integrated 6 * with the operating system. To ensure portability, follow 7 * these rules: 8 * 9 * * Always call SockInit() at the beginning of your program 10 * and check that it returns TRUE. 11 * 12 * * Use SockSend() & SockRecv() instead of read(), write(), 13 * send(), or recv() when working with sockets. 14 * 15 * * Use SockClose() instead of close() with sockets. 16 * 17 * * Use SOCK_ERRNO when using functions that use or return 18 * sockets, such as SockSend() or accept(). 19 * 20 * * Use HOST_ERRNO when using gethostbyname() or gethostbyaddr() 21 * functions. 22 * 23 * * As far as I can tell, getservbyname() and related functions 24 * never set any error variable. 25 * 26 * * Use SockStrError() & HostStrError() to convert SOCK_ERRNO 27 * and HOST_ERRNO to error strings. 28 * 29 * * In .MAK files, include $(TCPIP_MAK) & use $(TCPIPLIB) 30 * when linking applications using TCP/IP. 31 * 32 ****************************************************************/ 33 34 #if !defined( IN_TCPIP_H ) 35 #define IN_TCPIP_H 36 37 #include <sys/types.h> 38 #include <sys/stat.h> 39 #include <sys/socket.h> 40 #include <sys/ioctl.h> 41 #include <netinet/in.h> 42 #include <netdb.h> 43 #include <errno.h> 44 45 #if defined( TCPIP_IBM ) 46 /* Here comes some ugly stuff: The watcom compiler and the IBM TCPIP 47 * toolkit do not work together very well. The return codes for the 48 * socket calls are not integrated into the usual error codes, there 49 * are separate values instead. This results in a crash for two values. 50 * Since these values are not needed for socket access as far as I can 51 * see, I will save those values and redefine them after including 52 * nerrno.h (types.h will include nerrno.h, so this is needed here). 53 */ 54 # ifdef __WATCOMC__ 55 /* First check the numeric values */ 56 # if ENAMETOOLONG != 35 57 # error "ENAMETOOLONG: value unknown" 58 # endif 59 # if ENOTEMPTY != 39 60 # error "ENOTEMPTY: value unknown" 61 # endif 62 # undef ENAMETOOLONG 63 # undef ENOTEMPTY 64 # include <nerrno.h> 65 # undef ENAMETOOLONG 66 # undef ENOTEMPTY 67 # define ENAMETOOLONG 35 68 # define ENOTEMPTY 39 69 # endif 70 # include <types.h> 71 # if !defined( TCPIP_IBM_NOHIDE ) 72 # define send IbmSockSend 73 # define recv IbmSockRecv 74 # endif 75 #endif 76 77 #if defined( TCPIP_IBM ) 78 # define BSD_SELECT 79 # include <sys/select.h> 80 # include <sys/time.h> 81 # include <nerrno.h> 82 # include <utils.h> 83 # if defined( MICROSOFT ) 84 # define SOCK_ERRNO (tcperrno()) 85 # else 86 # define SOCK_ERRNO (sock_errno()) 87 # endif 88 # define HOST_ERRNO (h_errno) 89 # define SockClose(S) soclose(S) 90 # define SockInit() (!sock_init()) 91 # define SockSend IbmSockSend 92 # define SockRecv IbmSockRecv 93 94 const char *HostStrError(int HostErrno); 95 const char *SockStrError(int SockErrno); 96 97 int IbmSockSend (int Socket, const void *Buffer, int Len, int Flags); 98 int IbmSockRecv (int Socket, const void *Buffer, int Len, int Flags); 99 100 #if !defined( h_errno ) 101 extern int h_errno; /* IBM forgot to declare this in current header files */ 102 #endif 103 104 #elif defined( __unix ) 105 # if defined( sgi ) /* SGI incorrectly defines FD_ZERO in sys/select.h */ 106 # include <bstring.h> 107 # endif 108 # if defined( sunos ) 109 extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); 110 # else 111 # include <sys/select.h> 112 # endif 113 # include <sys/time.h> 114 # include <errno.h> 115 # include <arpa/inet.h> 116 # define SOCK_ERRNO errno 117 # define HOST_ERRNO h_errno 118 # define SockClose(S) close(S) 119 # define SockInit() TRUE 120 # define SockSend send 121 # define SockRecv recv 122 # define SockStrError(E) strerror(E) 123 124 const char *HostStrError( int HostErrno ); 125 126 #else 127 # error Undefined version of TCP/IP specified 128 129 #endif 130 131 #endif 132