diff options
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -175,20 +175,26 @@ socket_set_low_latency(int sfd) assert_return(sfd >= 0); - /* FIXME: could make this configurable */ - option = true; - if (setsockopt(sfd, SOL_SOCKET, SO_KEEPALIVE, &option, sizeof(option)) < 0) - error("setsockopt: %m"); + /* Probably not necessary, but can't hurt */ + if (cfg->socket_defer) { + option = true; + if (setsockopt(sfd, SOL_SOCKET, SO_KEEPALIVE, &option, sizeof(option)) < 0) + error("setsockopt: %m"); + } /* Doubtful if it has much effect, but can't hurt */ - option = IPTOS_LOWDELAY; - if (setsockopt(sfd, IPPROTO_IP, IP_TOS, &option, sizeof(option)) < 0) - error("setsockopt: %m"); + if (cfg->socket_iptos) { + option = IPTOS_LOWDELAY; + if (setsockopt(sfd, IPPROTO_IP, IP_TOS, &option, sizeof(option)) < 0) + error("setsockopt: %m"); + } /* Nagle's algorithm is a poor fit for gaming */ - option = true; - if (setsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, &option, sizeof(option)) < 0) - error("setsockopt: %m"); + if (cfg->socket_nodelay) { + option = true; + if (setsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, &option, sizeof(option)) < 0) + error("setsockopt: %m"); + } } void |