Add a configuration option for TCP keepalives (SO_KEEPALIVE), default off.
[sgt/putty] / telnet.c
index f421cc5..6f4f54c 100644 (file)
--- a/telnet.c
+++ b/telnet.c
@@ -674,7 +674,7 @@ static void telnet_sent(Plug plug, int bufsize)
 static const char *telnet_init(void *frontend_handle, void **backend_handle,
                               Config *cfg,
                               char *host, int port, char **realhost,
-                              int nodelay)
+                              int nodelay, int keepalive)
 {
     static const struct plug_function_table fn_table = {
        telnet_closing,
@@ -710,8 +710,10 @@ static const char *telnet_init(void *frontend_handle, void **backend_handle,
        sfree(buf);
     }
     addr = name_lookup(host, port, realhost, &telnet->cfg);
-    if ((err = sk_addr_error(addr)) != NULL)
+    if ((err = sk_addr_error(addr)) != NULL) {
+       sk_addr_free(addr);
        return err;
+    }
 
     if (port < 0)
        port = 23;                     /* default telnet port */
@@ -727,12 +729,10 @@ static const char *telnet_init(void *frontend_handle, void **backend_handle,
        sfree(buf);
     }
     telnet->s = new_connection(addr, *realhost, port, 0, 1,
-                              nodelay, (Plug) telnet, &telnet->cfg);
+                              nodelay, keepalive, (Plug) telnet, &telnet->cfg);
     if ((err = sk_socket_error(telnet->s)) != NULL)
        return err;
 
-    sk_addr_free(addr);
-
     /*
      * Initialise option states.
      */