Subversion Repositories Games.Carmageddon

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Inspiration taken from https://github.com/TheAssemblyArmada/Vanilla-Conquer/blob/vanilla/common/sockets.h
  3.  */
  4.  
  5. #ifndef HARNESS_WINSOCK_H
  6. #define HARNESS_WINSOCK_H
  7.  
  8. #include <assert.h>
  9.  
  10. #ifdef _WIN32
  11. #define _WINSOCK_DEPRECATED_NO_WARNINGS
  12. #include <winsock2.h>
  13. #include <ws2tcpip.h>
  14.  
  15. #else /* Assume posix style sockets on non-windows */
  16.  
  17. #include <arpa/inet.h>
  18. #include <errno.h>
  19. #include <fcntl.h>
  20. #include <netdb.h> // for getaddrinfo() and freeaddrinfo()
  21. #include <sys/ioctl.h>
  22. #include <sys/socket.h>
  23. #include <sys/types.h>
  24. #include <unistd.h> // for close()
  25.  
  26. #define closesocket(x) close(x)
  27. #define WSAEISCONN EISCONN
  28. #define WSAEINPROGRESS EINPROGRESS
  29. #define WSAEALREADY EALREADY
  30. #define WSAEADDRINUSE EADDRINUSE
  31. #define WSAEADDRNOTAVAIL EADDRNOTAVAIL
  32. #define WSAEBADF EBADF
  33. #define WSAECONNREFUSED ECONNREFUSED
  34. #define WSAEINTR EINTR
  35. #define WSAENOTSOCK ENOTSOCK
  36. #define WSAEWOULDBLOCK EWOULDBLOCK
  37. #define WSAEINVAL EINVAL
  38. #define WSAETIMEDOUT ETIMEDOUT
  39.  
  40. #define MAKEWORD(x, y) ((y) << 8 | (x))
  41.  
  42. typedef struct WSADATA {
  43. } WSADATA;
  44.  
  45. int WSAStartup(int version, WSADATA* data);
  46. int WSAGetLastError(void);
  47. int WSACleanup(void);
  48. int ioctlsocket(int handle, long cmd, unsigned long* argp);
  49.  
  50. #endif /* _WIN32 */
  51.  
  52. #endif
  53.