bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Better patch to add disabling Nagle algorithm


From: Wallace Owen
Subject: Better patch to add disabling Nagle algorithm
Date: Mon, 09 Jul 2001 15:04:10 -0700

Here's that same patch, in unified diff format (all the better for
patch).  Sorry about the last one.


  // Wally
diff -r -u CommonC++-1.5.0/posix/socket.cpp 
CommonC++-1.5.0-withnagleopt/posix/socket.cpp
--- CommonC++-1.5.0/posix/socket.cpp    Wed Jun 27 06:50:25 2001
+++ CommonC++-1.5.0-withnagleopt/posix/socket.cpp       Mon Jul  9 13:27:31 2001
@@ -49,6 +49,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <cstdlib>
+#include <netinet/tcp.h>
 #include <strstream>
 
 #ifdef WIN32
@@ -335,6 +336,17 @@
                return Error(SOCKET_ROUTING_DENIED);
 #endif
        flags.route = enable;
+       return SOCKET_SUCCESS;
+}
+
+sockerror_t Socket::setNoDelay(bool enable)
+{
+       int opt = (enable ? 1 : 0);
+
+       if(setsockopt(so, IPPROTO_TCP, TCP_NODELAY, 
+                     (char *)&opt, (socklen_t)sizeof(opt)))
+               return Error(SOCKET_NODELAY_ERROR);
+
        return SOCKET_SUCCESS;
 }
 
diff -r -u CommonC++-1.5.0/posix/socket.h 
CommonC++-1.5.0-withnagleopt/posix/socket.h
--- CommonC++-1.5.0/posix/socket.h      Wed Jun 27 06:49:38 2001
+++ CommonC++-1.5.0-withnagleopt/posix/socket.h Mon Jul  9 13:25:49 2001
@@ -110,6 +110,7 @@
        SOCKET_SERVICE_UNAVAILABLE,
        SOCKET_MULTICAST_DISABLED,
        SOCKET_TIMEOUT_ERROR,
+       SOCKET_NODELAY_ERROR,
        SOCKET_EXTENDED_ERROR
 } sockerror_t;
 
@@ -563,6 +564,15 @@
         * @param enable normal routing when set to true.
         */
        sockerror_t setRouting(bool enable);
+
+
+       /**
+        * Enable/disable delaying packets (Nagle algorithm)
+        *
+        * @return 0 on success.
+        * @param disable Nagle algorithm when set to true.
+        */
+       sockerror_t setNoDelay(bool enable);
 
        /**
         * An unconnected socket may be created directly on the local

reply via email to

[Prev in Thread] Current Thread [Next in Thread]