From fb6c4cdfb4a70967ea51f4bb4a74c690b070b8a4 Mon Sep 17 00:00:00 2001 From: yhirose Date: Tue, 14 Dec 2021 17:29:50 -0500 Subject: [PATCH] Fixed problem with is_socket_alive --- httplib.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/httplib.h b/httplib.h index 583531b..dc328fc 100644 --- a/httplib.h +++ b/httplib.h @@ -2338,9 +2338,11 @@ inline bool wait_until_socket_is_ready(socket_t sock, time_t sec, time_t usec) { } inline bool is_socket_alive(socket_t sock) { + if (detail::select_read(sock, 0, 0) == 0) { + return true; + } char buf[1]; - return detail::select_read(sock, 0, 0) && - recv(sock, &buf[0], sizeof(buf), MSG_PEEK) != 0; + return recv(sock, &buf[0], sizeof(buf), MSG_PEEK) > 0; } class SocketStream : public Stream {