Planeshift
|
00001 00002 #ifndef __SOCKWIN_H__ 00003 #define __SOCKWIN_H__ 00004 00005 //#include <windows.h> 00006 #ifdef __CYGWIN__ 00007 // this avoid a warning in cygwin, we don't have to care about because we don't 00008 // use the FD_SET type macors 00009 #define USE_SYS_TYPES_FD_SET 00010 #endif 00011 00012 // Do not link in windows 00013 #define _INC_WINDOWS 00014 #include <winsock.h> 00015 #undef _INC_WINDOWS 00016 00017 00022 // INET_ADDRSTRLEN is defined in the ws2ipdef.h file for windows part of winsock 2. 00023 // Until that is included we need to include it her. 00024 #ifndef INET_ADDRSTRLEN 00025 #define INET_ADDRSTRLEN 22 00026 #endif 00027 00028 #define SOCK_SENDTO(a,b,c,d,e,f) sendto(a,(const char *)b,c,d,e,f) 00029 #define SOCK_RECVFROM(a,b,c,d,e,f) recvfrom(a,(char *)b,c,d,e,f) 00030 #define SOCK_IOCTL(a,b,c) ioctlsocket(a,b,(unsigned long *)c) 00031 #define SOCK_CLOSE(a) closesocket(a) 00032 #define SOCK_SELECT(max,read,write,except,timeout) select(max,read,write,except,timeout) 00033 00034 // hack, because on cygwin socklen_t is defined but not suitable for winsock 00035 #ifdef socklen_t 00036 #undef socklen_t 00037 #endif 00038 #define socklen_t int 00039 00040 static inline int initSocket() 00041 { 00042 WSADATA wsaData; 00043 WORD wVers = MAKEWORD(1, 1); 00044 return WSAStartup(wVers, &wsaData); 00045 } 00046 00047 static inline void exitSocket() 00048 { 00049 WSACleanup(); 00050 } 00051 00054 #endif 00055