--- _CVS_cURL_orig_jan/curl/src/main.c	2008-01-01 22:11:27.000000000 +0100
+++ _CVS_cURL_modif_jan/curl/src/main.c	2008-01-02 15:25:22.000000000 +0100
@@ -479,7 +479,12 @@
   char *libcurl; /* output libcurl code to this file name */
   bool raw;
   bool post301;
-  bool nokeepalive;
+
+  bool nokeepalive; /* for keepalive needs */
+  long tcp_keepidle;
+  long tcp_keepintvl;
+  long tcp_keepcnt;
+
   struct OutStruct *outs;
 };
 
@@ -714,6 +719,9 @@
     "    --socks4 <host[:port]> Use SOCKS4 proxy on given host + port",
     "    --socks5 <host[:port]> Use SOCKS5 proxy on given host + port",
     "    --stderr <file> Where to redirect stderr. - means stdout",
+    "    --tcp-keepcnt <number> Maximum number of keepalive probes",
+    "    --tcp-keepidle <seconds> Time before sending keepalive probes",
+    "    --tcp-keepintvl <seconds> Time between individual keepalive probes",
     " -t/--telnet-option <OPT=val> Set telnet option",
     "    --trace <file>  Write a debug trace to the given file",
     "    --trace-ascii <file> Like --trace but without the hex output",
@@ -1542,6 +1550,9 @@
     {"$#", "raw",        FALSE},
     {"$0", "post301",    FALSE},
     {"$1", "no-keep-alive",    FALSE},
+    {"$2", "tcp-keepcnt",    TRUE},
+    {"$3", "tcp-keepidle",    TRUE},
+    {"$4", "tcp-keepintvl",    TRUE},
 
     {"0", "http1.0",     FALSE},
     {"1", "tlsv1",       FALSE},
@@ -2001,6 +2012,21 @@
       case '1': /* --no-keep-alive */
         config->nokeepalive ^= TRUE;
         break;
+      case '2': /* --tcp-keepcnt */
+        /* there may be a problem if value is beyond the max value of a int */
+        if(str2num(&config->tcp_keepcnt, nextarg))
+          return PARAM_BAD_NUMERIC;
+        break;
+      case '3': /* --tcp-keepidle */
+        /* there may be a problem if value is beyond the max value of a int */
+        if(str2num(&config->tcp_keepidle, nextarg))
+          return PARAM_BAD_NUMERIC;
+        break;
+      case '4': /* --tcp-keepintvl */
+        /* there may be a problem if value is beyond the max value of a int */
+        if(str2num(&config->tcp_keepintvl, nextarg))
+          return PARAM_BAD_NUMERIC;
+        break;
       }
       break;
     case '#': /* --progress-bar */
@@ -4529,6 +4555,18 @@
         my_setopt(curl, CURLOPT_POST301, config->post301);
         if (!config->nokeepalive) {
           my_setopt(curl, CURLOPT_SOCKOPTFUNCTION, set_so_keepalive);
+
+          /* curl version to be defined */
+          if (config->tcp_keepcnt) {
+            my_setopt(curl, CURLOPT_TCP_KEEPCNT,config->tcp_keepcnt);
+          }
+          if (config->tcp_keepidle) {
+            my_setopt(curl, CURLOPT_TCP_KEEPIDLE, config->tcp_keepidle);
+          }
+          if (config->tcp_keepintvl) {
+            my_setopt(curl, CURLOPT_TCP_KEEPINTVL, config->tcp_keepintvl);
+          }
+
           my_setopt(curl, CURLOPT_SOCKOPTDATA, config);
         }
 
