keepalive timer?

Per Hedeland hedeland@REDACTED
Tue Jun 22 09:14:01 CEST 2004


David Hopwood <david.nospam.hopwood@REDACTED> wrote:
>
>Per Hedeland wrote:
>> 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.
>
>Yes it is: man 7 tcp

Well, I should have said "...wasn't in the man pages of the Linux
distribution where I used them", which was the admittedly dated RedHat
7.3.

>> 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.
>
>TCP_KEEPIDLE et al are not Linux-specific; AFAICS they seem to be supported
>on all BSD-derived TCP stacks (most Unices including OS X, also OpenVMS, but
>not Win32).

Interesting - do you have some other example of "most Unices"? The "BSD-
derived" would seem to be misleading, since they're not in the latest
and greatest FreeBSD (5.2.1), nor can I find them in the online tcp(4)
man pages of current OpenBSD or NetBSD. I also checked the tcp(7P) man
page of Solaris 8 and 9, not there either, though I did find an
apparently undocumented TCP_KEEPALIVE, that might possibly be a
setsockopt combining SO_KEEPALIVE and Linux TCP_KEEPIDLE, in the include
files of Solaris 8 (nothing corresponding to TCP_KEEPINTVL/TCP_KEEPCNT
though).

--Per



More information about the erlang-questions mailing list