[erlang-questions] Socket keepalive option

Greg Burri greg.burri@REDACTED
Mon Jun 16 08:57:39 CEST 2008


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 ?

/Greg


On Sat, Jun 14, 2008 at 12:17 PM, Per Hedeland <per@REDACTED> wrote:
> "Greg Burri" <greg.burri@REDACTED> wrote:
>>
>>Is it possible to set the option {keepalive, Boolean} to a socket by
>>the server side after the socket has been created ?
>
> I certainly think it should be, but haven't actually verified it.
>
>>I try to do that with an application under Yaws (http://yaws.hyber.org/) :
>>
>>out(A) ->
>>   inet:setopts(A#arg.clisock, [{active, true}, {keepalive, true}]),
>>   [..]
>>
>>When the server waits and it doesn't send data I capture the TCP
>>stream with Wireshark (http://www.wireshark.org/) and see if there is
>>some 'Ack' from the server... but I don't see anything..
>
> Depending on your OS, the timeout for starting keepalive probing is on
> the order of a couple of hours, so you need to be patient.:-) E.g.
> FreeBSD 7.0:
>
> $ sysctl -a | grep tcp.keep
> net.inet.tcp.keepidle: 7200000
> net.inet.tcp.keepintvl: 75000
> net.inet.tcp.keepinit: 75000
>
> tcp(4):
>
>  keepinit     Timeout, in milliseconds, for new, non-established TCP
>               connections.
>
>  keepidle     Amount of time, in milliseconds, that the connection
>               must be idle before keepalive probes (if enabled) are
>               sent.
>
>  keepintvl    The interval, in milliseconds, between keepalive
>               probes sent to remote machines.  After TCPTV_KEEPCNT
>               (default 8) probes are sent, with no response, the
>               connection is dropped.
>
> --Per Hedeland
>



More information about the erlang-questions mailing list