]> granicus.if.org Git - curl/commitdiff
tcpkeepalive: Support CURLOPT_TCP_KEEPIDLE on OSX
authorRobert Wruck <rwruck@users.sf.net>
Mon, 8 Apr 2013 21:13:05 +0000 (23:13 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 8 Apr 2013 21:13:05 +0000 (23:13 +0200)
MacOS X doesn't have TCP_KEEPIDLE/TCP_KEEPINTVL but only a single
TCP_KEEPALIVE (see
http://developer.apple.com/library/mac/#DOCUMENTATION/Darwin/Reference/ManPages/man4/tcp.4.html).
Here is a patch for CURLOPT_TCP_KEEPIDLE on OSX platforms.

lib/connect.c

index e159a2b5ce7b8d37a4340df00b51240a2b6220df..6090abb36f6d83292d92a2d08552e2eb237a07ee 100644 (file)
@@ -148,6 +148,15 @@ tcpkeepalive(struct SessionHandle *data,
       infof(data, "Failed to set TCP_KEEPINTVL on fd %d\n", sockfd);
     }
 #endif
+#ifdef TCP_KEEPALIVE
+    /* Mac OS X style */
+    optval = curlx_sltosi(data->set.tcp_keepidle);
+    KEEPALIVE_FACTOR(optval);
+    if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPALIVE,
+          (void *)&optval, sizeof(optval)) < 0) {
+      infof(data, "Failed to set TCP_KEEPALIVE on fd %d\n", sockfd);
+    }
+#endif
 #endif
   }
 }