[Spread-users] Fixes for java implementation

Johannes Wienke jwienke at techfak.uni-bielefeld.de
Wed Oct 9 13:03:58 EDT 2013


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

-------------- next part --------------
From b9388cb8a4c01c9c59e8cc87df917c64c51e1cde Mon Sep 17 00:00:00 2001
From: Johannes Wienke <jwienke at techfak.uni-bielefeld.de>
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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.spread.org/pipermail/spread-users/attachments/20131009/addbd0eb/attachment.bin 


More information about the Spread-users mailing list