mirror of
https://gitee.com/wangbin579/cetus.git
synced 2024-12-03 12:27:42 +08:00
Support keepalive for TCP connections
This commit is contained in:
parent
af01f4adff
commit
21a36691eb
@ -283,6 +283,18 @@ network_socket_connect_setopts(network_socket *sock)
|
||||
if (setsockopt(sock->fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val)) != 0) {
|
||||
g_critical("%s: setsockopt SO_KEEPALIVE failed: %s (%d)", G_STRLOC, g_strerror(errno), errno);
|
||||
}
|
||||
val = 30;
|
||||
if (setsockopt(sock->fd, SOL_TCP, TCP_KEEPIDLE, &val, sizeof(val)) != 0) {
|
||||
g_critical("%s: setsockopt TCP_KEEPIDLE failed: %s (%d)", G_STRLOC, g_strerror(errno), errno);
|
||||
}
|
||||
val = 5;
|
||||
if (setsockopt(sock->fd, SOL_TCP, TCP_KEEPINTVL, &val, sizeof(val)) != 0) {
|
||||
g_critical("%s: setsockopt TCP_KEEPINTVL failed: %s (%d)", G_STRLOC, g_strerror(errno), errno);
|
||||
}
|
||||
val = 3;
|
||||
if (setsockopt(sock->fd, SOL_TCP, TCP_KEEPCNT, &val, sizeof(val)) != 0) {
|
||||
g_critical("%s: setsockopt TCP_KEEPCNT failed: %s (%d)", G_STRLOC, g_strerror(errno), errno);
|
||||
}
|
||||
|
||||
/*
|
||||
* the listening side may be INADDR_ANY,
|
||||
|
Loading…
Reference in New Issue
Block a user