Fix build on macos

This commit is contained in:
loonycyborg 2019-01-30 13:22:14 +03:00
parent 85446b93dd
commit 136d88451e

View file

@ -83,9 +83,14 @@ void server_base::accept_connection(const boost::system::error_code& error, sock
int timeout = 30;
int cnt = 10;
int interval = 30;
#ifdef __linux__
setsockopt(socket->native_handle(), SOL_TCP, TCP_KEEPIDLE, &timeout, sizeof(timeout));
setsockopt(socket->native_handle(), SOL_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt));
setsockopt(socket->native_handle(), SOL_TCP, TCP_KEEPINTVL, &interval, sizeof(interval));
#endif
#if defined(__APPLE__) && defined(__MACH__)
setsockopt(socket->native_handle(), IPPROTO_TCP, TCP_KEEPALIVE, &timeout, sizeof(timeout));
#endif
}
#endif