cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to pause ftp upload?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 27 May 2009 08:30:01 +0200 (CEST)

On Tue, 26 May 2009, m. allan noah wrote:

> Well, I guess what I was looking for was an interface like zlib, where you
> provide a buffer, and the library drains it at your request, and then we
> refill the buffer. But it seems like I cannot do that with a single-threaded
> program and the easy interface, since curl_easy_perform wants to complete
> the entire job. Though, it would seem that multi has the ability to step
> each of its easy handles the way I want? Is my understanding correct?

The multi interface is certainly much closer to what you've asked for.

> I switched to multi interface, and return CURL_READFUNC_PAUSE from my
> callback, and call curl_easy_pause directly on the easy handle when I have
> some more data to send. Does that seem safe?

Yes it does.

> Semantically, I dont want to 'pause' exactly, i just want a way to return
> 'no data now', without curl closing the connection. Perhaps something like
> CURL_READFUNC_RETRY (-2)?

"no data now" means pausing. The thing is that your callback gets called when
the remote site is ready to receive, and thus you have but two choices: you
either provide data to send or you pause. Saying you want a "retry" would mean
that the callback would be called again instantly since the remote site is
still ready to receive data and a busy-loop won't do you much good!

> Oh- and thanks loads for libcurl, its a real life-saver. (rock-box ain't bad
> either :)

Thanks, these are two of my primary open source involvements...

-- 
  / daniel.haxx.se
Received on 2009-05-27