cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Persistent connections with libCurl

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 28 Apr 2010 16:41:54 +0200 (CEST)

On Wed, 28 Apr 2010, Rahul R wrote:

Please don't top-post.

> To reuse the handles, consider i have to connect to multiple hosts A, B, C
> and D and send requests initially using handles hA, hB, hC and hD to send
> requests to A, B, C and D respectively.
>
> Now, if i decide to reuse the handles i can reuse any of these handles to
> connect to any of the hosts and still be able to achieve persistent
> connections ?

You'd preferably only use a single handle and use that to do all the requests
with. Then it'll re-use and do persistent connections as far as possible.

> For example, i can use hA to connect to hosts B, C, D also and later on
> whenever i use hA for host A, B, C or D the cached connection will be
> used.(As every handle caches 5 connections).

The default cache is 5 connections, and you can change it with
CURLOPT_MAXCONNECTS. Additionally, there's a DNS cache and a SSL session id
cache etc that makes it worthwhile to always design libcurl-using apps to make
sure they re-use handles as much as possible.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-04-28