summaryrefslogtreecommitdiffstats
path: root/mbbsd/mbbsd.c
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-07 17:48:59 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-07 17:48:59 +0800
commitee57b0ef4c119439d166d8fb7c9b44d850a3263c (patch)
treeedb03ac8d515d2e7c1146d1f959c13f3505d48b6 /mbbsd/mbbsd.c
parenta03f510b71af8506ac9b23e55a0d129e8945690e (diff)
downloadpttbbs-ee57b0ef4c119439d166d8fb7c9b44d850a3263c.tar
pttbbs-ee57b0ef4c119439d166d8fb7c9b44d850a3263c.tar.gz
pttbbs-ee57b0ef4c119439d166d8fb7c9b44d850a3263c.tar.bz2
pttbbs-ee57b0ef4c119439d166d8fb7c9b44d850a3263c.tar.lz
pttbbs-ee57b0ef4c119439d166d8fb7c9b44d850a3263c.tar.xz
pttbbs-ee57b0ef4c119439d166d8fb7c9b44d850a3263c.tar.zst
pttbbs-ee57b0ef4c119439d166d8fb7c9b44d850a3263c.zip
* experimental sending keepalive packets (hope this can reduce user's auto-disconnect issue)
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4512 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/mbbsd.c')
-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));