use SO_KEEPALIVE option on all sockets do detect dead sockets

This commit is contained in:
schmirl
2009-09-04 13:24:30 +00:00
parent 1474cdf799
commit 0e9e22c23d
3 changed files with 7 additions and 0 deletions

View File

@@ -124,6 +124,10 @@ bool cTBSocket::Accept(const cTBSocket &Listener) {
if (::getsockname(socket, (struct sockaddr*)&m_LocalAddr, &addrlen) == -1)
return false;
int sol=1;
// Ignore possible errors here, proceed as usual
::setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, &sol, sizeof(sol));
if (!cTBSource::Open(socket))
return false;