diff --git a/src/include/libks/ks.h b/src/include/libks/ks.h index a553614..4a5d65c 100644 --- a/src/include/libks/ks.h +++ b/src/include/libks/ks.h @@ -35,6 +35,9 @@ /* libks version as a number */ #define KS_VERSION_NUM 20001 +/* Use this to allow enabling TCP_KEEPIDLE and TCP_KEEPINTVL socket options */ +//#define KS_KEEP_IDLE_INTVL 1 + #include "libks/ks_platform.h" #include "libks/ks_types.h" diff --git a/src/ks_socket.c b/src/ks_socket.c index f871db1..26bf254 100644 --- a/src/ks_socket.c +++ b/src/ks_socket.c @@ -88,10 +88,12 @@ KS_DECLARE(ks_status_t) ks_socket_option(ks_socket_t socket, int option_name, ks case TCP_NODELAY: case SO_KEEPALIVE: case SO_LINGER: +#ifdef KS_KEEP_IDLE_INTVL #ifndef __APPLE__ case TCP_KEEPIDLE: case TCP_KEEPINTVL: #endif +#endif /* KS_KEEP_IDLE_INTVL */ #ifdef WIN32 result = setsockopt(socket, SOL_SOCKET, option_name, (char *) &opt, sizeof(opt)); #else diff --git a/src/kws.c b/src/kws.c index 75e0975..1bbb26f 100644 --- a/src/kws.c +++ b/src/kws.c @@ -636,10 +636,12 @@ static void setup_socket(ks_socket_t sock) ks_socket_option(sock, KS_SO_NONBLOCK, KS_TRUE); ks_socket_option(sock, TCP_NODELAY, KS_TRUE); ks_socket_option(sock, SO_KEEPALIVE, KS_TRUE); +#ifdef KS_KEEP_IDLE_INTVL #ifndef __APPLE__ ks_socket_option(sock, TCP_KEEPIDLE, 30); ks_socket_option(sock, TCP_KEEPINTVL, 30); #endif +#endif /* KS_KEEP_IDLE_INTVL */ } static void restore_socket(ks_socket_t sock)