curl-users
Re: GET reply problem
Date: Wed, 15 Jun 2005 15:28:27 +0100
Dan Fandrich wrote:
>On Wed, Jun 15, 2005 at 12:53:43PM +0100, Pedro Neves wrote:
>
>
>>Let me try to explain it better: If I compare the text file produced as
>>a reply to the GET operation with the packet using ethereal, I can see
>>in ethereal that the packet has been correctly sent (is completed), but
>>in the text file it stops in the middle of the packet. As a resullt, my
>>program crashes.
>>
>>
>
>Two things to look at: are you closing your file properly when the transfer
>is complete?
>
I am not sure, but probably not. I should call the fclose(), rigth?
Anyway, I send you the functions that I am calling:
*....*
*/curl_easy_setopt(handle, CURLOPT_URL, url_mac_addr_config);
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, teste);
curl_easy_setopt(handle, CURLOPT_WRITEDATA, &file);
curl_easy_perform(handle);
....
/*
The structure and the function that I am using are the following:
/*struct Ftpfile
{
char *filename;
FILE *stream;
};
struct Ftpfile file={"teste.txt", NULL};
size_t teste(void *source, size_t size, size_t nmemb, void *stream)
{
struct Ftpfile *out = (struct Ftpfile *) stream;
if(out && !out->stream)
{
out->stream = fopen(out->filename, "w");
if(!out->stream)
return -1;
}
return fwrite(source, size, nmemb, out->stream);
}
*/
>And are you writing every data block to the file from your
>write callback function, regardless of the site of the data block?
>
>
Sorry, but I didnt understood the question. Are you asking me if I am
writing to file everytime I call the URL?
Thanks in advance.
Pedro
>
>
>>>>Dan
>>>>
>>>>
Received on 2005-06-15