cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Keepalive

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 18 Mar 2008 23:41:45 +0100 (CET)

On Tue, 18 Mar 2008, Tim McClarren wrote:

>> With recent libcurls there's no reason at all to twiddle around, as the
>> connection cache is then kept by the multi handle so you can kill and
>> re-use easy handles all you want and the re-using of connections should
>> still work fine!
>
> "kill and re-use" means "destroy old ones and create new ones"? "re-use"
> sounds like "reinitialize an existing one".

Yes, I meant that you can do it either way as the connection isn't associated
with the individual easy handle anymore after each request is completed.

>> No. But there's nothing in that an application author in general should
>> need to consider or even bother about.
>
> Fair enough. Does just the host and port part of the URL need to match, and
> nothing else?

It depends on the protocol, but for HTTP it is _basically_ only host and port
for the non-proxy using case. There are several minor common cases it also
takes into account. See lib/url.c:ConnectionExists()

> Is there anything beyond the transport endpoints that libcurl looks at
> inside the easy handle to decide which open socket it might try to use, if
> any?

libcurl has a pool of existing connections (previous connections you've done
and that is left alive) and when you setup a new request, it will scan through
the existing ones to see if there is one that can be re-used. If not it'll
create a fresh new one.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2008-03-18