From 0676a1a88579163530dddf6e41c9f0a7c2a7b380 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Thu, 9 May 2013 12:00:28 +1000 Subject: [PATCH] Use TCP_NODELAY with raw sockets if !opt_delaynet --- util.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/util.c b/util.c index 76a5eca6..330b49e0 100644 --- a/util.c +++ b/util.c @@ -203,12 +203,13 @@ static void keep_sockalive(SOCKETTYPE fd) { const int tcp_keepidle = 45; const int tcp_keepintvl = 30; - const int keepalive = 1; - const int tcp_keepcnt = 1; + const int tcp_one = 1; - setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (const void *)&keepalive, sizeof(keepalive)); + setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (const void *)&tcp_one, sizeof(tcp_one)); + if (!opt_delaynet) + setsockopt(fd, SOL_TCP, TCP_NODELAY, (const void *)&tcp_one, sizeof(tcp_one)); # ifdef __linux - setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &tcp_keepcnt, sizeof(tcp_keepcnt)); + setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &tcp_one, sizeof(tcp_one)); setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &tcp_keepidle, sizeof(tcp_keepidle)); setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &tcp_keepintvl, sizeof(tcp_keepintvl)); # endif /* __linux */