diff options
Diffstat (limited to 'lib/net/common.c')
-rw-r--r-- | lib/net/common.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/net/common.c b/lib/net/common.c index 6ed19ad..084d48d 100644 --- a/lib/net/common.c +++ b/lib/net/common.c @@ -1,8 +1,8 @@ #include "./common.h" -const uint32_t TCPALIVE_IDLE_TIME = 30; -const uint32_t TCPALIVE_CHECK_INTVL = 10; -const uint32_t TCPALIVE_CHECK_CNT = 5; +const uint32_t TCPALIVE_IDLE_TIME = 3; +const uint32_t TCPALIVE_CHECK_INTVL = 1; +const uint32_t TCPALIVE_CHECK_CNT = 2; struct sockaddr_in* get_addr(const char* addr, const char* port) { struct addrinfo hints; @@ -44,6 +44,13 @@ int conn_configure_tcpalive(conn_t* conn) { return -1; } + struct timeval tv = { + .tv_sec = TCPALIVE_IDLE_TIME, + }; + if (setsockopt(conn->conn_socket_fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) { + return -1; + } + setsockopt_arg = TCPALIVE_IDLE_TIME; if (setsockopt(conn->conn_socket_fd, IPPROTO_TCP, TCP_KEEPIDLE, &setsockopt_arg, sizeof(setsockopt_arg)) == -1) { return -1; |