Commit 0676a1a88579163530dddf6e41c9f0a7c2a7b380

ckolivas 2013-05-09T12:00:28

Use TCP_NODELAY with raw sockets if !opt_delaynet

diff --git a/util.c b/util.c
index 76a5eca..330b49e 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 */