From 6e1297cab01c2a4b1f68f82681d048361c5faff3 Mon Sep 17 00:00:00 2001 From: yhirose Date: Tue, 7 Jul 2020 18:55:46 -0400 Subject: [PATCH] Fix #150 (#556) --- httplib.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/httplib.h b/httplib.h index ffc4b2a..0eb8aca 100644 --- a/httplib.h +++ b/httplib.h @@ -5321,7 +5321,24 @@ inline SSLSocketStream::SSLSocketStream(socket_t sock, SSL *ssl, : sock_(sock), ssl_(ssl), read_timeout_sec_(read_timeout_sec), read_timeout_usec_(read_timeout_usec), write_timeout_sec_(write_timeout_sec), - write_timeout_usec_(write_timeout_usec) {} + write_timeout_usec_(write_timeout_usec) { + { + timeval tv; + tv.tv_sec = static_cast(read_timeout_sec); + tv.tv_usec = static_cast(read_timeout_usec); + + setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast(&tv), + sizeof(tv)); + } + { + timeval tv; + tv.tv_sec = static_cast(write_timeout_sec); + tv.tv_usec = static_cast(write_timeout_usec); + + setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, reinterpret_cast(&tv), + sizeof(tv)); + } +} inline SSLSocketStream::~SSLSocketStream() {} @@ -5803,4 +5820,3 @@ inline bool SSLClient::check_host_name(const char *pattern, #endif // CPPHTTPLIB_HTTPLIB_H -