commit 419684dcd9ed6ece9200c30438bffb9e9de855cd
parent 4e5d01e3836bd9b0db0e005595389e54e12398f9
Author: sin <sin@2f30.org>
Date: Fri, 8 Apr 2016 17:19:22 +0100
set tcp keepalive option
Diffstat:
1 file changed, 2 insertions(+), 0 deletions(-)
diff --git a/stun.c b/stun.c
@@ -585,6 +585,7 @@ serversetup(int devfd)
ms2tv(&tv, RCVTIMEO);
setsockopt(netfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ setsockopt(netfd, SOL_SOCKET, SO_KEEPALIVE, (int []){1}, sizeof(int));
setsockopt(netfd, IPPROTO_TCP, TCP_NODELAY, (int []){1}, sizeof(int));
if (challenge(netfd) < 0 || response(netfd) < 0) {
@@ -634,6 +635,7 @@ clientsetup(int devfd)
ms2tv(&tv, RCVTIMEO);
setsockopt(netfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ setsockopt(netfd, SOL_SOCKET, SO_KEEPALIVE, (int []){1}, sizeof(int));
setsockopt(netfd, IPPROTO_TCP, TCP_NODELAY, (int []){1}, sizeof(int));
if (response(netfd) < 0 || challenge(netfd) < 0) {