SocketIncludes.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #ifndef RAKNET_SOCKETINCLUDES_H
  2. #define RAKNET_SOCKETINCLUDES_H
  3. // All this crap just to include type SOCKET
  4. #ifdef __native_client__
  5. #define _PP_Instance_ PP_Instance
  6. #else
  7. #define _PP_Instance_ int
  8. #endif
  9. #if defined(WINDOWS_STORE_RT)
  10. #include <windows.h>
  11. #include "WinRTSockAddr.h"
  12. typedef Windows::Networking::Sockets::DatagramSocket^ __UDPSOCKET__;
  13. typedef Windows::Networking::Sockets::StreamSocket^ __TCPSOCKET__;
  14. typedef unsigned int socklen_t;
  15. #define FORMAT_MESSAGE_ALLOCATE_BUFFER 0
  16. #define FIONBIO 0
  17. #define LocalFree(x)
  18. // using Windows.Networking;
  19. // using Windows.Networking.Sockets;
  20. // See http://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.sockets.datagramsocketcontrol
  21. #elif defined(_WIN32)
  22. // IP_DONTFRAGMENT is different between winsock 1 and winsock 2. Therefore, Winsock2.h must be linked againt Ws2_32.lib
  23. // winsock.h must be linked against WSock32.lib. If these two are mixed up the flag won't work correctly
  24. // WinRT: http://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.sockets
  25. // Sample code: http://stackoverflow.com/questions/10290945/correct-use-of-udp-datagramsocket
  26. #include <winsock2.h>
  27. typedef SOCKET __UDPSOCKET__;
  28. typedef SOCKET __TCPSOCKET__;
  29. typedef int socklen_t;
  30. #else
  31. #define closesocket close
  32. #include <unistd.h>
  33. #include <sys/types.h>
  34. #include <sys/socket.h>
  35. #include <netinet/in.h>
  36. #include <arpa/inet.h>
  37. #include <unistd.h>
  38. #include <fcntl.h>
  39. #ifdef __native_client__
  40. #include "ppapi/cpp/private/net_address_private.h"
  41. #include "ppapi/c/pp_bool.h"
  42. #include "ppapi/c/pp_errors.h"
  43. #include "ppapi/cpp/completion_callback.h"
  44. #include "ppapi/cpp/instance_handle.h"
  45. #include "ppapi/cpp/module.h"
  46. #include "ppapi/cpp/module_impl.h"
  47. #include "ppapi/c/pp_errors.h"
  48. #include "ppapi/c/pp_module.h"
  49. #include "ppapi/c/pp_var.h"
  50. #include "ppapi/c/pp_resource.h"
  51. #include "ppapi/c/ppb.h"
  52. #include "ppapi/c/ppb_instance.h"
  53. #include "ppapi/c/ppb_messaging.h"
  54. #include "ppapi/c/ppb_var.h"
  55. #include "ppapi/c/ppp.h"
  56. #include "ppapi/c/ppb_core.h"
  57. #include "ppapi/c/ppp_instance.h"
  58. #include "ppapi/c/ppp_messaging.h"
  59. #include "ppapi/c/pp_input_event.h"
  60. #include "ppapi/c/pp_completion_callback.h"
  61. //UDP specific - the 'private' folder was copied from the chromium src/ppapi/c headers folder
  62. #include "ppapi/c/private/ppb_udp_socket_private.h"
  63. #include "ppapi/cpp/private/net_address_private.h"
  64. typedef PP_Resource __UDPSOCKET__;
  65. typedef PP_Resource __TCPSOCKET__;
  66. #else
  67. //#include "RakMemoryOverride.h"
  68. /// Unix/Linux uses ints for sockets
  69. typedef int __UDPSOCKET__;
  70. typedef int __TCPSOCKET__;
  71. #endif
  72. #endif
  73. #endif // RAKNET_SOCKETINCLUDES_H
粤ICP备19079148号