curl-library
Re: curl_multi_socket problem, not reading all data
Date: Mon, 20 Oct 2008 17:52:49 -0700
On Tue, Oct 21, 2008 at 01:40:49AM +0200, Ragnar Lonn wrote:
> I'm experimenting with using libcurl to simulate multiple web clients  
> fetching things from a webserver, but I must be doing something wrong  
> somewhere. I've scanned the list archives and read the docs but can't  
> understand why it won't work! What happens is my program will only read  
> part of the data from the webserver. I.e. if I run the program and tell  
> it to perform 1 fetch of an URL that I know is 8 kB, it will execute and  
> report getting around 2 kB when it finishes.
>
> What seems to happen is libcurl sets running_handles to 0, which makes me 
> stop execution but not all data will have been read at that point. Maybe I 
> have misunderstood something about how it is supposed to work?
>
> Any help would be very appreciated. I'll include the code below. It uses  
> epoll and has been tested on a Linux (Ubuntu) machine.
[...]
> size_t client_write_data(void *buffer, size_t size, size_t nmemb, void  
> *userp) {
>  total_bytes += (unsigned int)(nmemb * size);
> }
You're not returning anything from the write callback.  Which means that
libcurl treats the garbage that is returned as a code to abort the download.
You should really turn on warnings in your compiler to catch this kind
of thing.
>>> Dan
-- http://www.MoveAnnouncer.com The web change of address service Let webmasters know that your web site has movedReceived on 2008-10-21