Set TCPNODELAY as default.

This commit is contained in:
Endre Sándor Varga 2013-03-05 14:22:21 +01:00
parent 370d6451c7
commit 852afeb565
2 changed files with 4 additions and 0 deletions

View file

@ -50,6 +50,8 @@ object Tcp extends ExtensionKey[TcpExt] {
* [[akka.io.Inet.SocketOption]] to enable or disable TCP_NODELAY
* (disable or enable Nagle's algorithm)
*
* Please note, that TCP_NODELAY is enabled by default.
*
* For more information see [[java.net.Socket.setTcpNoDelay]]
*/
case class TcpNoDelay(on: Boolean) extends SocketOption {

View file

@ -109,6 +109,8 @@ private[io] abstract class TcpConnection(val channel: SocketChannel,
/** used in subclasses to start the common machinery above once a channel is connected */
def completeConnect(commander: ActorRef, options: immutable.Traversable[SocketOption]): Unit = {
// Turn off Nagle's algorithm by default
channel.socket.setTcpNoDelay(true)
options.foreach(_.afterConnect(channel.socket))
commander ! Connected(