From aca4821babd7b6eed20b114a9f6c26e8f978198f Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Tue, 5 Dec 2017 11:07:29 +0100 Subject: Http: set socket recv/send timeout (30s) --- src/Http.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Http.hpp b/src/Http.hpp index 1058564..2c3b13a 100644 --- a/src/Http.hpp +++ b/src/Http.hpp @@ -357,6 +357,10 @@ socket_t create_socket(const char* host, int port, Fn fn, int socket_flags = 0) // Make 'reuse address' option available int yes = 1; setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&yes, sizeof(yes)); + // set a less conservative socket timeout + yes = 30000; // 30s timeout + setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&yes, sizeof(yes)); + setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char*)&yes, sizeof(yes)); // bind or connect if (fn(sock, *rp)) { -- cgit v1.2.3