[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SLUG] Re: TCP keepalives



On Tue, Jun 27, 2000 at 10:19:22PM +1000, Howard Lowndes wrote:
> Does anyone know whether Linux TCP stacks use keepalives.  If not how can
> I get to use them.  I seem to have a problem with one end of a telnet
> session dying and the other end not knowing that it has died, it still
> shows as ESTABLISHED, or sometimes as CLOSED, in a netstat -a listing.

its up to the application to turn it on.

 int on = 1;
 setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on));

this sends a keep alive every 3 hours (on linux, usually 2 elsewhere).
the timeout and other paramaters can be changed *on a host-wide level*
by messing with /proc/sys/net/ipv4/tcp_keepalive_*. see tcp(7)


posix1.g also specifies a TCP_KEEPALIVE value which is supposedly
able to be set per connection, using:

 setsockopt(s, IPPROTO_TCP, TCP_KEEPALIVE, &val, sizeof(val));

but i don't believe linux (or much else) implements that (or at least,
my linux man pages don't mention it)



my telnetd(8) lists:
  -n           Disable TCP keep-alives.  Normally in.telnetd enables the
               TCP keep-alive mechanism to probe connections that have been
               idle for some period of time to determine if the client is
               still there, so that idle connections from machines that
               have crashed or can no longer be reached may be cleaned up.

.. which implies that its on by default.

-- 
 - Gus
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to slug-request@nospam.slug.org.au with
unsubscribe in the text