Commit d46e7ee8 authored by louiz’'s avatar louiz’

Enable TCP keepalive on sockets

parent eb2a2e75
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment