cURL / Mailing Lists / curl-library / Single Mail


Re: Multi-handle hanging up immediately after creating FTP data socket (using GCD)

From: Bill Doyle <>
Date: Fri, 9 Aug 2013 12:05:44 -0400

On Thu, Aug 8, 2013 at 5:28 PM, Daniel Stenberg <> wrote:
> This wording makes me curious. What timer interval are you talking about?
> Your event dispatcher should monitor all file descriptors/sockets you've
> asked it to monitor and tell you when the timeout is reached. There should
> be no timer interval involved!

Alright, this might be one of the points that's causing me trouble
then. So when the CURLMOPT_TIMERFUNCTION is told to set a timeout, is
it always supposed to be a one-time thing? GCD's timers are
interval-based, so if that's the case then I'll either have to do some
trickery to stop them again after the first time they run, or switch
to using dispatch_after().

In the parenthesized portion of that sentence, I'm referring to when I
initially set up the timer source's block and give it to GCD. I'm
simply reusing the same timer source whenever libcurl requests a
timeout, so when I initially create the CURLHandle object, since
nothing has been added yet, I just don't set the interval. It appears
that this has the desired effect of "doing nothing", but I'm working
on confirming that. If I switch to dispatch_after(), of course, that
will be irrelevant.

> Okay so after you've called curl_multi_add_handle() to add that brand new
> easy handle to the multi handle, what libcurl function do you call then? If
> you don't explicitly call a function, you then just call one when the next
> action happens?

I'm not calling anything after adding the handle. Should I be? I
thought that libcurl would set the first timeout when I added a handle
and do everything on its own from there on out. It appears to connect
to the server just fine the way I'm doing it now, but if I'm missing a
step, that would explain a lot.

> I think you're talking about TCP keepalive here? I recommend
> CURLOPT_TCP_KEEPALIVE and friends instead for that!

To be honest, I just copied it verbatim from the GCD example that I
was following. Didn't even have it in there originally, I just wanted
to see if it would have any effect on it. If I do end up needing it,
I'll definitely switch to libcurl's built-in option.
List admin:
Received on 2013-08-09