20 #ifndef VISIONTRANSFER_NETWORKING_H 21 #define VISIONTRANSFER_NETWORKING_H 25 #define snprintf _snprintf_s 31 #define _WIN32_WINNT 0x501 33 #define _WINSOCK_DEPRECATED_NO_WARNINGS 61 #define EWOULDBLOCK WSAEWOULDBLOCK 62 #define ECONNRESET WSAECONNRESET 63 #define ETIMEDOUT WSAETIMEDOUT 64 #define EPIPE WSAECONNABORTED 65 #define MSG_DONTWAIT 0 66 #define SHUT_WR SD_BOTH 68 #define close closesocket 73 #define errno WSAGetLastError() 74 #define strerror win_strerror 76 inline std::string win_strerror(
unsigned long error) {
78 if(FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
79 FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
80 nullptr, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
81 (LPSTR)&str, 0,
nullptr) == 0 || str ==
nullptr) {
82 return "Unknown error";
85 snprintf(buffer,
sizeof(buffer),
"%s (%lu)", str, error);
87 return std::string(buffer);
92 typedef int socklen_t;
95 #include <arpa/inet.h> 96 #include <netinet/tcp.h> 97 #include <sys/types.h> 98 #include <sys/socket.h> 99 #include <sys/select.h> 101 #include <netinet/in.h> 109 #define INVALID_SOCKET -1 112 #define WSA_IO_PENDING 0 113 #define WSAECONNRESET 0