Add a configuration option for TCP keepalives (SO_KEEPALIVE), default off.
[u/mdw/putty] / unix / uxnet.c
index 1e7d51b..08fb4e1 100644 (file)
@@ -378,7 +378,7 @@ Socket sk_register(OSSocket sockfd, Plug plug)
 }
 
 Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
-             int nodelay, Plug plug)
+             int nodelay, int keepalive, Plug plug)
 {
     int s;
 #ifdef IPV6
@@ -433,6 +433,11 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
        setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (void *) &b, sizeof(b));
     }
 
+    if (keepalive) {
+       int b = TRUE;
+       setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, (void *) &b, sizeof(b));
+    }
+
     /*
      * Bind to local address.
      */