[erlang-questions] Socket keepalive option

Per Hedeland <>
Tue Jun 17 15:26:18 CEST 2008


"Edwin Fine" <> wrote:
>
>Isn't he asking if there is any way to do this on a per-process basis,
>rather than for every process in the system?

There's no mention of "per-process" in the question, so lacking
telepathic capabilities I have to assume that he isn't - what he *is*
asking is "from erlang code without changing the global system value"
(where "the global system value" is obviously the same as "for every
process in the system"), and that's what my answer covered. Either way,
"per-socket using setsockopt(), and only on Linux" is the only answer I
know of that doesn't involve changing the global system value.

--Per

>On Mon, Jun 16, 2008 at 7:19 PM, Per Hedeland <> wrote:
>
>> "Greg Burri" <> wrote:
>> >
>> >Thanks for your reply and explanation.
>> >
>> >I have theses values for a Debian distribution (Linux 2.6.25-2-amd64) :
>> >#> sysctl -a | grep keepalive
>> >net.ipv4.tcp_keepalive_time = 7200
>> >net.ipv4.tcp_keepalive_probes = 9
>> >net.ipv4.tcp_keepalive_intvl = 75
>> >
>> >Theses values are in second, so the tcp_keepalive_timetime is 2 hours.
>> >Is it possible to set this value directly from erlang code without
>> >changing the global system value ?
>>
>> On Linux (only, as far as I know), you can set those parameters per
>> socket with setsockopt() calls, see tcp(7). Of course there is no direct
>> support for those in Erlang, but you should be able to do them with the
>> "raw" form of Option for inet:setopts/2.
>>
>> --Per



More information about the erlang-questions mailing list