cURL / Mailing Lists / curl-library / Single Mail


Re: make only connect, but not issue GET request

From: Daniel Stenberg <>
Date: Wed, 23 Mar 2011 09:05:25 +0100 (CET)

On Tue, 22 Mar 2011, Pankaj Takawale wrote:

> I tried CONNECT_ONLY option after detecting broken connection using
> LASTSOCKET and noticed that curl_easy_perform reuses the same connection for
> further transfers.

You probably can, but I've already advised against it. We can discuss why and
odds of problems etc, but I still advice against using libcurl like that since
we haven't made it for that purpose and in fact there are good reasons why
libcurl won't work like that in the future.

But feel free to be adventurous. The code is there and its free and open, you
can do whatever you want more or less.

> This serves my purpose. After debugging latest libcurl source code I found
> that Curl_do_perform puts new connection (made using CONNECT_ONLY) into
> connection-cache for further reuse.[url.c:2105 connect_host]. Curl debug
> message after making connect only connection: "Connection #0 to host SERVER
> left intact" at next request : "Re-using existing connection! (#0) with host
> I'm worried of bug #63 mentioned in knownbugs.html about CONNECT_ONLY. Is it
> safe to use CONNECT_ONLY option in this case (I want to avoid HEAD option).
> Or do you see any glitch in it.

If you don't touch the connection any all apart from just connecting it, then
I don't see any glitch with it.

However, the CONNECT_ONLY/LASTSOCKET approach is typically used by
applications to get the socket and to fiddle with it somehow in the
application's own descretion and the tiniest little thing you do with the
connection behind libcurl's back will ruin its ability to reuse the
connection. Therefore, the chances of a CONNECT_ONLY/LASTSOCKET connection to
get re-used piecefully is next to none in practise and might be reason enough
for libcurl to more carefully make sure it doesn't happen. That's what #63 is

Also, please don't use another site than for accurate and
up-to-date libcurl information: there are lots of old lingering mirrors from
the days we had web mirrors and you seem to have found one of them.
Unfortunately I've not been able to have them all just go away.

List admin:
Received on 2011-03-23