cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Keepalive

From: Jamie Lokier <jamie_at_shareable.org>
Date: Wed, 19 Mar 2008 15:46:51 +0000

Gabriel Kälin wrote:
> TCP keep-alive indeed is a partial solution, but it doesn't solve the problem if the firewall is reconfigured or drops the connections anyway.

TCP keep-alive should solve that problem. If a firewall drops the
connection, TCP keep-alive will detect eventually that it's not
getting a response, and that will be flagged as a socket error.
Unfortunately the detection time is very long on some OSes, and
configurable by the app only on a few.

> I'm not that much bothered with TCP connections in the CLOSE_WAIT
> state, but when a new request is performed, I don't want libcurl to
> take too long until it figures out that the connection may be dead.

Unfortunately, there is no way to detect a dead connection other than
trying it, and waiting for a response. You can reduce the likelihood
of a long delay by only reusing connections that have been idle for
less than N seconds, when N is less than you expect firewall timeouts
to be. (Unfortunately I've seen firewall timeouts less than 30
seconds in real life).

-- Jamie
Received on 2008-03-19