diff -ru -I '\$Id:' net.old/ipsvd-0.12.1/src/socket_bind.c net/ipsvd-0.12.1/src/socket_bind.c --- net.old/ipsvd-0.12.1/src/socket_bind.c 2006-02-04 14:16:48.000000000 -0500 +++ net/ipsvd-0.12.1/src/socket_bind.c 2013-12-26 15:47:25.166952124 -0500 @@ -31,3 +31,9 @@ size -= (size >> 5); } } + +int socket_keepalive(int s) +{ + int opt = 1; + return setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,&opt,sizeof opt); +} diff -ru -I '\$Id:' net.old/ipsvd-0.12.1/src/socket.h net/ipsvd-0.12.1/src/socket.h --- net.old/ipsvd-0.12.1/src/socket.h 2006-02-04 14:16:48.000000000 -0500 +++ net/ipsvd-0.12.1/src/socket.h 2013-12-26 15:47:25.167952137 -0500 @@ -18,5 +18,6 @@ extern int socket_remote4(int,char *,uint16 *); extern void socket_tryreservein(int,int); +extern int socket_keepalive(int); #endif diff -ru -I '\$Id:' net.old/ipsvd-0.12.1/src/tcpsvd.c net/ipsvd-0.12.1/src/tcpsvd.c --- net.old/ipsvd-0.12.1/src/tcpsvd.c 2006-02-04 14:16:47.000000000 -0500 +++ net/ipsvd-0.12.1/src/tcpsvd.c 2013-12-26 15:48:10.644538719 -0500 @@ -32,9 +32,9 @@ #endif #ifdef SSLSVD -#define USAGE " [-Ehpv] [-u user] [-c n] [-C n:msg] [-b n] [-l name] [-i dir|-x cdb] [-t sec] [-U ssluser] [-/ root] [-Z cert] [-K key] host port prog" +#define USAGE " [-Ehkpv] [-u user] [-c n] [-C n:msg] [-b n] [-l name] [-i dir|-x cdb] [-t sec] [-U ssluser] [-/ root] [-Z cert] [-K key] host port prog" #else -#define USAGE " [-Ehpv] [-u user] [-c n] [-C n:msg] [-b n] [-l name] [-i dir|-x cdb] [-t sec] host port prog" +#define USAGE " [-Ehkpv] [-u user] [-c n] [-C n:msg] [-b n] [-l name] [-i dir|-x cdb] [-t sec] host port prog" #endif #define VERSION "$Id: tcpsvd.c,v 1.24 2006/02/03 19:30:24 pape Exp $" @@ -54,6 +54,7 @@ unsigned long cnum =0; unsigned long cmax =30; unsigned long timeout =0; +unsigned int keepalive =0; unsigned int ucspi =1; const char *instructs =0; @@ -241,6 +242,8 @@ else run =prog; if ((fd_move(0, c) == -1) || (fd_copy(1, 0) == -1)) drop("unable to set filedescriptor"); + if (keepalive) + socket_keepalive(0); sig_uncatch(sig_term); sig_uncatch(sig_pipe); sig_uncatch(sig_child); @@ -271,10 +274,10 @@ #ifdef SSLSVD while ((opt =getopt(argc, (const char **)argv, - "c:C:i:x:u:l:Eb:hpt:vVU:/:Z:K:")) != opteof) { + "c:C:i:x:u:l:Eb:hkpt:vVU:/:Z:K:")) != opteof) { #else while ((opt =getopt(argc, (const char **)argv, - "c:C:i:x:u:l:Eb:hpt:vV")) != opteof) { + "c:C:i:x:u:l:Eb:hpkt:vV")) != opteof) { #endif switch(opt) { case 'c': scan_ulong(optarg, &cmax); if (cmax < 1) usage(); break; @@ -297,6 +300,7 @@ case 'E': ucspi =0; break; case 'b': scan_ulong(optarg, &backlog); break; case 'h': lookuphost =1; break; + case 'k': keepalive =1; break; case 'p': lookuphost =1; paranoid =1; break; case 't': scan_ulong(optarg, &timeout); break; case 'v': ++verbose; break;