summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-02-08 08:14:24 +0100
committerFlorent Le Coz <louiz@louiz.org>2014-02-08 08:14:24 +0100
commitd46e7ee8c90a800e6f3c2f1db949e88635983b6b (patch)
treeb473cd3300bc8c56bfbf0314f86b72697c17f149 /src/network
parenteb2a2e75c257735c3aa0548ad5a374931ea7da65 (diff)
downloadbiboumi-d46e7ee8c90a800e6f3c2f1db949e88635983b6b.tar.gz
biboumi-d46e7ee8c90a800e6f3c2f1db949e88635983b6b.tar.bz2
biboumi-d46e7ee8c90a800e6f3c2f1db949e88635983b6b.tar.xz
biboumi-d46e7ee8c90a800e6f3c2f1db949e88635983b6b.zip
Enable TCP keepalive on sockets
Diffstat (limited to 'src/network')
-rw-r--r--src/network/socket_handler.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/network/socket_handler.cpp b/src/network/socket_handler.cpp
index 3fe423e..ae9489d 100644
--- a/src/network/socket_handler.cpp
+++ b/src/network/socket_handler.cpp
@@ -21,6 +21,9 @@ SocketHandler::SocketHandler():
{
if ((this->socket = ::socket(AF_INET, SOCK_STREAM, 0)) == -1)
throw std::runtime_error("Could not create socket");
+ int optval = 1;
+ if (::setsockopt(this->socket, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) == -1)
+ log_warning("Failed to enable TCP keepalive on socket: " << strerror(errno));
}
std::pair<bool, std::string> SocketHandler::connect(const std::string& address, const std::string& port)