cURL / Mailing Lists / curl-library / Single Mail


Re: curl_easy_cleanup Not Closing Connections

From: François Veyres <>
Date: Wed, 20 Feb 2013 11:36:09 +0100

On Wed, Feb 20, 2013 at 9:55 AM, Linus Nielsen Feltzing <>wrote:

> On 02/20/2013 09:22 AM, François Veyres wrote:
>> I'm using libcurl 7.22, and doing a simple FTP get via the multi
>> interface. Everything works fine, but I notice when the transfer is
>> complete and I do a curl_easy_cleanup() the FTP control connection is
>> not closed. When I do a curl_multi_cleanup() and curl_global_cleanup()
>> the control connection is indeed closed.
>> Looking at the CHANGES I can't see anything that would affect this in
>> later releases. Is this a known problem, or am I misunderstanding
>> something?
> Curl keeps the FTP connection open even after the easy handle is closed,
> so the connection can be reused for subsequent FTP transfers to/from the
> same host.
> You could try the CURLOPT_FORBID_REUSE option if you really need to close
> the connection immediately.

That's not how I understood the behaviour... From the curl_easy_cleanup()
manpage, "This will effectively close all connections this handle has used
and possibly has kept open until now."

In my case there will be 100's of thousands of clients, each doing multiple
FTP gets, so I want the control connection to persist but I can't afford to
keep it open when the transfers are done. I tried setting
CURLOPT_FORBID_REUSE = 1 after the last transfer but before calling
curl_easy_cleanup() but that didn't close the control connection.

So is there a way for me to immediately close the connection after I'm
finished my transfers?



List admin:
Received on 2013-02-20