cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: stop downloading after x bytes?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 10 Jan 2006 11:07:34 +0100 (CET)

On Tue, 10 Jan 2006, Andrew wrote:

> I have tried calling the close function within the writedata procedure....
> however it segfaults :(

That is perfectly understandable as you're effectively cutting off the branch
you're sitting on when doing that.

> - Is it possible to close the connection (without trying to free the
> structure) from the writedata call itself (and then free from within the
> main program)?

That's not what you want to do. You want to *return* out from the callback and
have the transfer aborted. And that is done by returning a failure from thr
write callback (return any value that is not the total number of bytes you
received as input).

curl_easy_cleanup() etc should then be used by your app as normally.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2006-01-10