summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)