Skip to content

Commit

Permalink
Replace SOL_TCP with IPPROTO_TCP
Browse files Browse the repository at this point in the history
SOL_TCP is deprecated and doesn't exist on all platforms (e.g. FreeBSD).
IPPROTO_TCP is equivalent and portable.
  • Loading branch information
Faidon Liambotis committed Jan 10, 2019
1 parent 98c0148 commit 6452486
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ void enable_keepalive(int socket) {
debug(DBG_NOTICE, "TCP Keepalive feature might be limited on this platform");
#else
optval = 3;
if(setsockopt(socket, SOL_TCP, TCP_KEEPCNT, &optval, optlen) < 0) {
if(setsockopt(socket, IPPROTO_TCP, TCP_KEEPCNT, &optval, optlen) < 0) {
debug(DBG_ERR, "enable_keepalive: setsockopt TCP_KEEPCNT failed");
}
optval = 10;
if(setsockopt(socket, SOL_TCP, TCP_KEEPIDLE, &optval, optlen) < 0) {
if(setsockopt(socket, IPPROTO_TCP, TCP_KEEPIDLE, &optval, optlen) < 0) {
debug(DBG_ERR, "enable_keepalive: setsockopt TCP_KEEPIDLE %d failed", optval);
}
optval = 10;
if(setsockopt(socket, SOL_TCP, TCP_KEEPINTVL, &optval, optlen) < 0) {
if(setsockopt(socket, IPPROTO_TCP, TCP_KEEPINTVL, &optval, optlen) < 0) {
debug(DBG_ERR, "enable_keepalive: setsockopt TCP_KEEPINTVL failed");
}
#endif
Expand Down

0 comments on commit 6452486

Please sign in to comment.