On Thu, 9 May 2013, Török Edwin wrote:

Is there a way to tell curl to do connection caching per IP instead of per-host? i.e. can I tell it to check its cache only *after* my OPENSOCKET_FUNCTION callback is invoked (which might change the IP)?

Nope. And even if it was, why would it need to create a socket if it was in the cache?

libcurl simply tries very hard to re-use connections to the same host name and it offers no particular way for you to force it to load balance the requets between a number of IP addresses.

I could use CURLOPT_FRESHCONNECT to force a new connection, but then I won't be able to reuse my connection with 127.0.1.1 ever. Would it help if I return the cached socket from OPENSOCKETFUNCTION callback, and CURL_SOCKOPT_ALREADY_CONNECTED from CURLOPT_SOCKOPT_FUNCTION?

I don't understand how that is what you ask for. I thought you wanted the second request to the same host name to use _another_ IP address than the first one? Then I don't see how returning a "cached socket" helps. (Although I'll admit I don't follow you completely of what you meant.)

I think we'd need some new controls to be added for this to become possible.

--

 / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to