diff --git a/lib/roken/roken-common.h b/lib/roken/roken-common.h index 267643dc7..f2dc0ff4a 100644 --- a/lib/roken/roken-common.h +++ b/lib/roken/roken-common.h @@ -456,6 +456,10 @@ socket_set_reuseaddr (rk_socket_t, int); ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL socket_set_ipv6only (rk_socket_t, int); +#define socket_set_keepalive rk_socket_set_keepalive +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +socket_set_keepalive (rk_socket_t, int); + #define socket_to_fd rk_socket_to_fd ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL socket_to_fd(rk_socket_t, int); diff --git a/lib/roken/socket.c b/lib/roken/socket.c index 0a8612557..9feb343f5 100644 --- a/lib/roken/socket.c +++ b/lib/roken/socket.c @@ -305,6 +305,16 @@ socket_set_ipv6only (rk_socket_t sock, int val) #endif } +/* + * Set the that the `sock' keepalive setting. + */ + +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +socket_set_keepalive(rk_socket_t sock, int val) +{ + setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&val, sizeof(val)); +} + /** * Create a file descriptor from a socket * diff --git a/lib/roken/version-script.map b/lib/roken/version-script.map index 1a996b102..5bef85e14 100644 --- a/lib/roken/version-script.map +++ b/lib/roken/version-script.map @@ -123,6 +123,7 @@ HEIMDAL_ROKEN_2.0 { rk_socket_set_any; rk_socket_set_debug; rk_socket_set_ipv6only; + rk_socket_set_keepalive; rk_socket_set_nonblocking; rk_socket_set_port; rk_socket_set_portrange;