/* * PARSEC HEADER: net_wrap.h */ #ifndef _NET_UNP_H_ #define _NET_UNP_H_ #if defined( SYSTEM_TARGET_WINDOWS ) && ( _WIN32_WINNT >= _WIN32_WINNT_VISTA ) #include #include #include #else #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif /* #elif defined( SYSTEM_MACOSX_UNUSED ) #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define socklen_t int #endif */ // constants and macros used by the network code ------------------------------ // #define MAXLINE 4096 #define SA struct sockaddr // windows uses closesocket, osx/linux use close #ifdef SYSTEM_TARGET_WINDOWS #define CLOSESOCKET closesocket #else #define CLOSESOCKET close #endif // define some macros to make error handling more readable -------------------- // #ifdef SYSTEM_TARGET_WINDOWS #define ERRNO wsaerr #define FETCH_ERRNO() int wsaerr = WSAGetLastError() #define ERRNO_EWOULDBLOCK ( wsaerr == WSAEWOULDBLOCK ) #define ERRNO_ECONNREFUSED ( wsaerr == WSAECONNREFUSED ) #define ERRNO_ENETDOWN ( wsaerr == WSAENETDOWN ) #define ERRNO_ECONNRESET ( wsaerr == WSAECONNRESET ) //#define ERRNO_WSAEMSGSIZE ( wsaerr == WSAEMSGSIZE ) // UNP legacy stuff #define ioctl( fd, request, arg ) ioctlsocket(fd, request, (unsigned long *) arg) #define bzero(ptr,n) memset(ptr, 0, n) int inet_aton(const char *cp, struct in_addr *ap); const char* hstrerror(int); #if ( _WIN32_WINNT < _WIN32_WINNT_VISTA ) const char* inet_ntop( int family, const void* addrptr, char* strptr, size_t len); #endif #else #define ERRNO errno #define FETCH_ERRNO() {} #define ERRNO_EWOULDBLOCK ( errno == EWOULDBLOCK ) #define ERRNO_ECONNREFUSED ( errno == ECONNREFUSED ) #define ERRNO_ECONNRESET ( errno == ECONNRESET ) #define ERRNO_ENETDOWN ( FALSE ) #endif #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 1024 #endif #endif // _NET_UNP_H_