cURL / Mailing Lists / curl-library / Single Mail


Re: How to close established by libcurl FTP connections

From: Robert Iakobashvili <>
Date: Mon, 6 Aug 2007 14:25:04 +0300

On 8/6/07, Daniel Stenberg <> wrote:
> On Mon, 6 Aug 2007, Robert Iakobashvili wrote:
> >> Remove an easy handle from a multi handle would certainly not be right
> >> either, I would say. And there as well, the connection is owned by the
> >> multi handle and not by the individual easy handle after a completed
> >> transfer.
> Haha, well I do seem to recall that the world is habitated by a few other
> souls than just you and me, so there are at least a few other
> possibilities...

Hope so... :)

As I see it, the problem for a generic API for both the easy interface and
> the
> multi interface is that the connection is not "owned" by the easy
> interface in
> the latter case, and when you've detached an easy interface from the multi
> handle it's not even possible to know what multi handle that used to host
> it
> either.
> So, do you have any suggested proto or API how this should/could be done
> by an
> application?

I will try to come with:
a) some usage cases first,
b) that will allow to define required behavior,
c) and enable to define some API;

> What is even worse, that setting the bit of FRESH_CONNECT for a handle
> busy
> > with a FTP does open fresh FTP connections (data and control), but
> without
> > closing old connections.
> Well, libcurl is rather agressively trying to maintain persistent
> connections
> so it doesn't close any connection unless told so (unless it runs the
> connection cache full), and you (effectively) tell it to close by using
> CURLOPT_FORBID_REUSE - but that is of course set _before_ a transfer is
> made.

This is a very good point.

When both FRESH_CONNECT and FORBID_REUSE have been set the behavior of a
cycling FTP-handle, making FTP downloads and sleeping for several seconds in
was a half way to the desired, namely:

1) an established control FTP-connection was closed immediately just after a
file transfer is accomplished;

2) an established data FTP-connection was not closed after transfer, and was
kept during sleeping time;
   the connection was closed only after a new data connection opened by a
new transfer cycle;

Robert Iakobashvili,
coroberti %x40 gmail %x2e com
A web testing and traffic generation tool.
Received on 2007-08-06