Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Set keepalive on Unix socket
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Jan 29, 2019
1 parent 1c85f15 commit 7bb0688
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libweb3jsonrpc/UnixSocketServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ bool UnixDomainSocketServer::StartListening()
::bind(m_socket, reinterpret_cast<sockaddr*>(&m_address), sizeof(sockaddr_un));
fs::permissions(m_path, fs::owner_read | fs::owner_write);
listen(m_socket, 128);

int keepalive = 1;
if (setsockopt(m_socket, SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof(keepalive) < 0)
{
CloseConnection(m_socket);
m_socket = -1;
unlink(m_path.c_str());
return false;
}
}
return IpcServerBase::StartListening();
}
Expand Down

0 comments on commit 7bb0688

Please sign in to comment.