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 {