summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mbbsd/mbbsd.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 0fe860e1..c6d9f182 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -1462,8 +1462,15 @@ set_connection_opt(int sock)
const struct linger lin = {0};
// keep alive: server will check target connection (default 2 hours)
- const int on = 1;
+ const int on = 1;
setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void*)&on, sizeof(on));
+
+#if defined(SOL_TCP) && defined(TCP_KEEPIDLE)
+ {
+ const int idle = 300*2; // experimental, minimal keep alive check
+ setsockopt(sock, SOL_TCP, TCP_KEEPIDLE, (void*)idle, sizeof(idle));
+ }
+#endif
// fast close
setsockopt(sock, SOL_SOCKET, SO_LINGER, &lin, sizeof(lin));