Re: Fixes for java implementation

Johannes Wienke <[email protected]> Wed, 09 Oct 2013 19:03:58 +0200
Newsgroups gmane.network.spread.user
Message-ID <[email protected]>
On 09.10.13 18:50 schrieb John Schultz:
> Johannes, could you point to or send the code that would turn off Nagle's algorithm on the Java side?

It's attached in my original message as a patch. But also in this one now ;)

Cheers,
Johannes

_______________________________________________
Spread-users mailing list
[email protected]
http://lists.spread.org/mailman/listinfo/spread-users
0001-Allow-to-set-tcp-nodelay-flag.patch (text/plain, 1.5 KB)
From b9388cb8a4c01c9c59e8cc87df917c64c51e1cde Mon Sep 17 00:00:00 2001
From: Johannes Wienke <[email protected]>
Date: Tue, 27 Aug 2013 10:57:00 +0200
Subject: [PATCH 1/2] Allow to set tcp nodelay flag

Add a method that allows to toggle the tcp nodelay flag on the socket
used by SpreadConnection. If enabled, small messages are not accumulated
to bigger chunks and hence sent immediately, which prevents unwanted
delays.
---
 spread/SpreadConnection.java |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/spread/SpreadConnection.java b/spread/SpreadConnection.java
index 0c1ebe0..d6d2b82 100644
--- a/spread/SpreadConnection.java
+++ b/spread/SpreadConnection.java
@@ -1027,6 +1027,29 @@ NOT SUPPORTED IN 1.1	*/
 		}
 	}
 	
+	// Enable/disable TCP_NODELAY on the socket used for this connection.
+	/////////////////////////////////
+	/**
+	 * Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm) on the
+	 * socket used for this connection.
+	 *
+	 * @param  noDelay  If TCP_NODELAY should be enabled or not.
+	 * @throws  SpreadException  if we could not set the TCP_NODELAY flag.
+	 */
+	public void setTcpNoDelay(boolean noDelay) throws SpreadException
+	{
+		try
+		{
+			socket.setTcpNoDelay(noDelay);
+		}
+		catch (SocketException e)
+		{
+			SpreadException se = new SpreadException("setTcpNoDelay(): " + e.getMessage());
+			se.initCause(e);
+			throw se;
+		}
+	}
+
 	// Gets the user's private group.
 	/////////////////////////////////
 	/**
-- 
1.7.9.5
signature.asc (application/pgp-signature, 260 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (Darwin)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlJVjH8ACgkQBFcR5UV/ccLhEgCfQ7S7C5j0q134oS/h39gllHuN
+CUAn2bSN5uhu7MqUSczj3eoD5EmM2v4
=mBKq
-----END PGP SIGNATURE-----