keepalive timer?

Per Hedeland hedeland@REDACTED
Mon Jun 21 18:29:33 CEST 2004

Matthias Lang <matthias@REDACTED> wrote:
>It appears that you can't configure the keepalive time on a per-socket
>basis, at least not under linux 2.4.25.

Actually you can - from live and working code on 2.4.20-ish:

        int one = 1, idle = 60, intvl = 5, cnt = 3;
        setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof(one));
        setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &idle, sizeof(idle));
        setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl));
        setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt));

(Those particular values are *not* suitable for your generic TCP session
though.) I think I found documentation of this on some random web page
(typical for Linux:-), it certainly isn't in the man pages. But you have
the source...:-)

> Maybe it's possible under
>other operating systems, probably not. I don't know enough about other
>OSs' TCP stacks to answer.

I'll add my two öre to the "probably not" vote.


More information about the erlang-questions mailing list