Re: Per-connection TCP_KEEPALIVE setting?
From: Philip Mak (pmak@aaanime.net)
Date: Sat Sep 20 2003 - 14:58:18 EST
On Sat, Sep 20, 2003 at 10:51:34PM +0300, Nick Patavalis wrote:
> > But I'm looking for an integer option that determines how often
> > keepalives are sent...
>
> I don't think you can do this on a per-connection basis. If it is a
> custom application protocol, you can of-course add your own keepalive
> messages. I was dealing with the same issue a couple of years ago, and
> ended-up doing exactly this.
The application is a MUSH/MUD, which uses TCP/IP and has no way of
sending a no-op so TCP/IP keepalive seems to be the only choice.
I found the option; it involves the TCP_KEEPIDLE socket option. Here
is the full solution in case it's useful to anyone:
int keepalive = 1;
int keepidle = 900;
/* sock is the socket */
setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *) &keepalive, sizeof(keepalive));
setsockopt(sock, SOL_TCP, TCP_KEEPIDLE, (void *) &keepidle, sizeof(keepidle));
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html