From 22a806ca6f622b428b44522e0568c218b50de417 Mon Sep 17 00:00:00 2001 From: Dimon4eg Date: Mon, 13 May 2019 08:21:56 +0300 Subject: [PATCH] fix for Windows (#69) * fix for Windows * fix condition * make condition only on Windows --- ixwebsocket/IXSocket.cpp | 2 +- ixwebsocket/IXWebSocket.cpp | 3 +-- ixwebsocket/IXWebSocketTransport.cpp | 4 ++++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ixwebsocket/IXSocket.cpp b/ixwebsocket/IXSocket.cpp index e6a67fc2..e2794229 100644 --- a/ixwebsocket/IXSocket.cpp +++ b/ixwebsocket/IXSocket.cpp @@ -73,7 +73,7 @@ namespace ix struct timeval timeout; timeout.tv_sec = timeoutMs / 1000; - timeout.tv_usec = (timeoutMs < 1000) ? 0 : 1000 * (timeoutMs % 1000); + timeout.tv_usec = 1000 * (timeoutMs % 1000); // Compute the highest fd. int sockfd = _sockfd; diff --git a/ixwebsocket/IXWebSocket.cpp b/ixwebsocket/IXWebSocket.cpp index b6ab2c81..0449e694 100644 --- a/ixwebsocket/IXWebSocket.cpp +++ b/ixwebsocket/IXWebSocket.cpp @@ -223,7 +223,6 @@ namespace ix uint32_t retries = 0; millis duration; - ix::WebSocketInitResult status; // Try to connect perpertually while (true) @@ -249,7 +248,7 @@ namespace ix } // Try to connect synchronously - status = connect(_handshakeTimeoutSecs); + ix::WebSocketInitResult status = connect(_handshakeTimeoutSecs); if (!status.success) { diff --git a/ixwebsocket/IXWebSocketTransport.cpp b/ixwebsocket/IXWebSocketTransport.cpp index b8286f6a..503b0c91 100644 --- a/ixwebsocket/IXWebSocketTransport.cpp +++ b/ixwebsocket/IXWebSocketTransport.cpp @@ -303,6 +303,10 @@ namespace ix } } +#ifdef _WIN32 + if (lastingTimeoutDelayInMs <= 0) lastingTimeoutDelayInMs = 20; +#endif + // poll the socket PollResultType pollResult = _socket->poll(lastingTimeoutDelayInMs);