]> granicus.if.org Git - curl/commitdiff
Use getprotobyname() to retrieve protocol number for TCP
authorGisle Vanem <gvanem@broadpark.no>
Sun, 26 Feb 2006 17:08:33 +0000 (17:08 +0000)
committerGisle Vanem <gvanem@broadpark.no>
Sun, 26 Feb 2006 17:08:33 +0000 (17:08 +0000)
(sorry, I don't know how to add this to the configure process).

lib/config-win32.h
lib/config.dj
lib/connect.c

index 59dd441300106ff557a972b9dba1b18f96cbd6a7..9b3d531d7e7a8990bcba7a0fcefd04c667de2e1f 100644 (file)
 /* Define if you have the getservbyname function.  */
 #define HAVE_GETSERVBYNAME 1
 
+/* Define if you have the getprotobyname function.  */
+#define HAVE_GETPROTOBYNAME
+
 /* Define if you have the gettimeofday function.  */
 /* #define HAVE_GETTIMEOFDAY 1 */
 
index 04cf4db41e94a4e3d3ebec73c914822707c8e1ba..6fc9513d4e1c2c241f53e821e28329234a47c545 100644 (file)
@@ -20,6 +20,7 @@
 #define HAVE_GETHOSTNAME       1
 #define HAVE_GETPASS           1
 #define HAVE_GETSERVBYNAME     1
+#define HAVE_GETPROTOBYNAME    1
 #define HAVE_GETTIMEOFDAY      1
 #define HAVE_INET_ADDR         1
 #define HAVE_INET_NTOA         1
index 787951136ee1515bbbfcbc25d04182c917189e3d..427a874319f78ffabd8a97acfedd1e06a19c5ecf 100644 (file)
@@ -619,7 +619,15 @@ static void tcpnodelay(struct connectdata *conn,
 #ifdef TCP_NODELAY
   struct SessionHandle *data= conn->data;
   socklen_t onoff = (socklen_t) data->set.tcp_nodelay;
-  if(setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (void *)&onoff,
+  int proto = IPPROTO_TCP;
+
+#ifdef HAVE_GETPROTOBYNAME
+  struct protoent *pe = getprotobyname("tcp");
+  if (pe)
+    proto = p->p_proto;
+#endif
+
+  if(setsockopt(sockfd, proto, TCP_NODELAY, (void *)&onoff,
                 sizeof(onoff)) < 0)
     infof(data, "Could not set TCP_NODELAY: %s\n",
           Curl_strerror(conn, Curl_ourerrno()));