Browse Source

Use TCP_NODELAY with raw sockets if !opt_delaynet

ckolivas 12 years ago
parent
commit
0676a1a885
1 changed files with 5 additions and 4 deletions
  1. 5 4
      util.c

+ 5 - 4
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 */