From 3b72d8415037a909a57f55ea376e10e36a879137 Mon Sep 17 00:00:00 2001 From: Christian Sousa Date: Thu, 6 Nov 2014 23:41:15 -0800 Subject: [PATCH] Disable Nagle's algorithm in server and client This commit disables the Nagle's algorithm to reduce delay when exchanging values between R and Ruby. --- lib/rinruby.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/rinruby.rb b/lib/rinruby.rb index 6ecc06e..c98d5ab 100644 --- a/lib/rinruby.rb +++ b/lib/rinruby.rb @@ -168,6 +168,7 @@ def initialize(*args) #{RinRuby_KeepTrying_Variable} <- TRUE while ( #{RinRuby_KeepTrying_Variable} ) { #{RinRuby_Socket} <- try(suppressWarnings(socketConnection("#{@hostname}", #{@port_number}, blocking=TRUE, open="rb")),TRUE) + setTCPNoDelay(#{RinRuby_Socket}, value=TRUE) if ( inherits(#{RinRuby_Socket},"try-error") ) { Sys.sleep(0.1) } else { @@ -180,6 +181,7 @@ def initialize(*args) r_rinruby_pull r_rinruby_parseable @socket = @server_socket.accept + @socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) echo(nil,true) if @platform =~ /.*-java/ # Redirect error messages on the Java platform end