22 boost::system::error_code ec;
23 socket.set_option(boost::asio::socket_base::keep_alive(
true), ec);
25 const int idle_seconds = 10;
26 const int interval_seconds = 5;
28 const auto handle = socket.native_handle();
29 ::setsockopt(handle, IPPROTO_TCP, TCP_KEEPIDLE, &idle_seconds,
sizeof(idle_seconds));
30 ::setsockopt(handle, IPPROTO_TCP, TCP_KEEPINTVL, &interval_seconds,
sizeof(interval_seconds));
31 ::setsockopt(handle, IPPROTO_TCP, TCP_KEEPCNT, &probes,
sizeof(probes));