[Swan] Problem with SAupdate when SA does not exist in the kernel

Thomas Geulig geulig at nentec.de
Thu Sep 12 15:45:53 EEST 2013


Am Donnerstag, 12. September 2013, 14:23:50 schrieb Philippe Vouters:
> I checked my existing C codes and I could only code SO_KEEPALIVE as an
> only on or off socket option. As far as it looks, there is no way for a
> programmer to adjust the KEEPALIVE timer from within his code.

It is possible to set the values like this:

void activate_tcp_keepalive(int my_socket)
{
    int optval;

    optval = 1;
    setsockopt(my_socket, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval));

    optval = 60;
    setsockopt(my_socket, SOL_TCP, TCP_KEEPIDLE, &optval, sizeof(optval));

    optval = 60;
    setsockopt(my_socket, SOL_TCP, TCP_KEEPINTVL, &optval, sizeof(optval));

    optval = 3;
    setsockopt(my_socket, SOL_TCP, TCP_KEEPCNT, &optval, sizeof(optval));
}

TCP_KEEPIDLE  : tcp_keepalive_time
TCP_KEEPINTVL : tcp_keepalive_intvl
TCP_KEEPCNT   : tcp_keepalive_probes

Best regards

Thomas




More information about the Swan mailing list