From 3e783c2172a05bf5557086301442e7b56aba78a2 Mon Sep 17 00:00:00 2001 From: David Wagner Date: Thu, 5 Dec 2013 19:29:33 +0100 Subject: remote-processor: configure the socket with the TCP_NODELAY option BZ: 154316 The "man 7 tcp" page speaks for itself: TCP_NODELAY If set, disable the Nagle algorithm. This means that segments are always sent as soon as possible, even if there is only a small amount of data. When not set, data is buffered until there is a sufficient amount to send out, thereby avoiding the frequent sending of small packets, which results in poor utilization of the network. The behaviour described above if this option is not set introduces a lot of overhead when several commands are sent with remote-processor because they are not sent in burst mode: instead, remote-processor wait for the answer to each command. See "man 7 tcp" for all the details. Change-Id: I6c8ede4428629a16e9a2927d73a2897873a57d37 Signed-off-by: David Wagner --- remote-processor/Socket.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'remote-processor') diff --git a/remote-processor/Socket.cpp b/remote-processor/Socket.cpp index 2ae8870..77582e2 100644 --- a/remote-processor/Socket.cpp +++ b/remote-processor/Socket.cpp @@ -31,11 +31,19 @@ #include #include #include +#include #include CSocket::CSocket() : _iSockFd(socket(AF_INET, SOCK_STREAM, 0)) { assert(_iSockFd != -1); + + int iNoDelay = 1; + // (see man 7 tcp) + // Setting TCP_NODELAY allows us sending commands and responses as soon as + // they are ready to be sent, instead of waiting for more data on the + // socket. + setsockopt(_iSockFd, IPPROTO_TCP, TCP_NODELAY, (char *)&iNoDelay, sizeof(iNoDelay)); } CSocket::CSocket(int iSockId) : _iSockFd(iSockId) -- cgit v1.1