From 93ad709dfd468989ff8b5dc8774b17059a4e3f99 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Sat, 12 Dec 2020 11:00:55 -0800 Subject: [PATCH] fix ws curl error message + some Windows warnings --- ixwebsocket/IXGetFreePort.cpp | 2 +- ixwebsocket/IXNetSystem.cpp | 2 +- ixwebsocket/IXNetSystem.h | 6 ++++++ ixwebsocket/IXSocketConnect.cpp | 2 +- ixwebsocket/IXSocketServer.h | 3 ++- ws/ws.cpp | 2 +- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ixwebsocket/IXGetFreePort.cpp b/ixwebsocket/IXGetFreePort.cpp index 3f806ddd..e69e8d3d 100644 --- a/ixwebsocket/IXGetFreePort.cpp +++ b/ixwebsocket/IXGetFreePort.cpp @@ -31,7 +31,7 @@ namespace ix int getAnyFreePort() { - int sockfd; + socket_t sockfd; if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { return getAnyFreePortRandom(); diff --git a/ixwebsocket/IXNetSystem.cpp b/ixwebsocket/IXNetSystem.cpp index 655a52d4..bfb98a01 100644 --- a/ixwebsocket/IXNetSystem.cpp +++ b/ixwebsocket/IXNetSystem.cpp @@ -45,7 +45,7 @@ namespace ix int poll(struct pollfd* fds, nfds_t nfds, int timeout) { #ifdef _WIN32 - int maxfd = 0; + socket_t maxfd = 0; fd_set readfds, writefds, errorfds; FD_ZERO(&readfds); FD_ZERO(&writefds); diff --git a/ixwebsocket/IXNetSystem.h b/ixwebsocket/IXNetSystem.h index 465f43de..5954d168 100644 --- a/ixwebsocket/IXNetSystem.h +++ b/ixwebsocket/IXNetSystem.h @@ -34,6 +34,12 @@ typedef unsigned long int nfds_t; namespace ix { +#ifdef _WIN32 + typedef SOCKET socket_t; +#else + typedef int socket_t; +#endif + bool initNetSystem(); bool uninitNetSystem(); diff --git a/ixwebsocket/IXSocketConnect.cpp b/ixwebsocket/IXSocketConnect.cpp index a11fb3b7..94ebc406 100644 --- a/ixwebsocket/IXSocketConnect.cpp +++ b/ixwebsocket/IXSocketConnect.cpp @@ -35,7 +35,7 @@ namespace ix { errMsg = "no error"; - int fd = socket(address->ai_family, address->ai_socktype, address->ai_protocol); + socket_t fd = socket(address->ai_family, address->ai_socktype, address->ai_protocol); if (fd < 0) { errMsg = "Cannot create a socket"; diff --git a/ixwebsocket/IXSocketServer.h b/ixwebsocket/IXSocketServer.h index a4573a96..f06f81ca 100644 --- a/ixwebsocket/IXSocketServer.h +++ b/ixwebsocket/IXSocketServer.h @@ -9,6 +9,7 @@ #include "IXConnectionState.h" #include "IXSelectInterrupt.h" #include "IXSocketTLSOptions.h" +#include "IXNetSystem.h" #include #include #include @@ -75,7 +76,7 @@ namespace ix int _addressFamily; // socket for accepting connections - int _serverFd; + socket_t _serverFd; std::atomic _stop; diff --git a/ws/ws.cpp b/ws/ws.cpp index 6a393bf5..2bf0bca2 100644 --- a/ws/ws.cpp +++ b/ws/ws.cpp @@ -1620,7 +1620,7 @@ namespace ix spdlog::info("Status: {}", response->statusCode); if (response->errorCode != HttpErrorCode::Ok) { - spdlog::info("error message: ", response->errorMsg); + spdlog::error("error message: {}", response->errorMsg); } if (!headersOnly && response->errorCode == HttpErrorCode::Ok)