On Tue, Jan 17, 2012, Daniel Stenberg wrote:
On Fri, 13 Jan 2012, Pierre Ynard wrote:
>libcurl tries each IP address sequentially and divides the timeout
>value between all of them. Let's say that I set a connection
>timeout of 2 seconds, which seems plenty reasonable for normally
>responsive hosts. Let's say that I hit a host pointing to 10 IP
>addresses. 2s / 10 = 200 ms, so despite my reasonable 2 seconds
>timeout, libcurl will try to connect to every IP with a timeout of
>only 200 ms.
Yeah. It has been one of those things nagging in the back of my head
for years and we really should improve it. The question is, of
course, what the best approach really is.
Might this be better done as example code for
CURLOPT_OPENSOCKETFUNCTION callback?
I like the pattern where there are up to N simultaneous connection
attempts: initially one attempt to a random address from the pool,
then after a timeout a second simultaneous attempt is started.
Once a connection is established, cancel the other connections.
With suitable parameters this is not unfair on the server side and
allows the maximum possible time for a slow server to respond.
However, it's too complicated to put into libcurl itself.
--
Tim Bannister - [email protected]
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html