cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: No error but libcurl returns CURLE_WRITE_ERROR

From: Juan Ignacio Hervás <jihervas_at_iies.es>
Date: Tue, 08 Apr 2003 11:05:08 +0200

At 09:29 06/04/2003 +0200, you wrote:
>On Fri, 4 Apr 2003, Juan Ignacio Hervás wrote:
>
>(I trust this is a recent version of libcurl you're talking about.)

Yes. I am working with libcurl 7.10.4-pre5 in Win32 (Windows XP).

> > When I call this code between three or four times (depends on the number of
> > files in the remote directory), curl_easy_perform returns
> > CURLE_WRITE_ERROR. The curl code is calling Curl_client_write (sendf.c) and
> > this function is working with a 4096 bytes buffer:
>
>Curl_client_write() doesn't use a buffer at all. Are you referring to a
>particular callback function?
Yes. You are right. It was my mistake. I was doing debug in fwrite.c (of
course, it doesn't belong to libcurl).
I have checked that this situation only happens if I don't use
CURLOPT_WRITEFUNCTION. In that case, I think, libcurl define its own fwrite
function and use stdout as the "file" to write.

I have attached a simple test source code that get files of a source
directory with FindFirstFile/FindNextFile API and connect to a remote FTP
server to check the size of these files.
If I don't define any write function (in fact, I don't need it), it fails
in the second call to Curl_client_write (type=CLIENTWRITE_BODY) : It sends
to the default write function a 2142 bytes buffer, so the second time it
calls Curl_client_write, it fails because 2142*2>4096. (Also I have
attached this 2142 bytes buffer, that belong to the content of the remote
directory).

I hope this source code can clarify my problem.

Thanks in advance.

> > In the first and second call it receives a buffer of 1993 bytes (these two
> > files are in the same remote directory) and in the third the buffer is 172
> > bytes long (but it has just 110 bytes left in its working buffer:
> > 4096-1993-1993=110). Then it calls _flsbuf(c, stream) in fwrite.c and
> > returns 110.
> > As 110 != 172, Curl_client_write returns CURLE_WRITE_ERROR.
>
>Isn't that correct? fwrite() should return "the number of items successfully
>written". If that isn't the same amout that was passed to it, something went
>wrong.
>
> > The next time I repeat the same routine it works (the internal working
> > buffer now is empty).
> >
> > So, is it a normal behaviour?
>
>I've never experienced something like this.
>
>What platform are you running this on?
>
> > or I should not care about CURLE_WRITE_ERROR in this routine?
>
>CURLE_WRITE_ERROR is returned when libcurl detects a write error as told by
>the function it uses.
>
> > Thanks in advance and sorry for the weird question in a Friday afternoon!
>
>Can you provide us a full source code of an app showing this problem (when
>running with libcurl 7.10.4)?
>
>--
> Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: ValueWeb:
>Dedicated Hosting for just $79/mo with 500 GB of bandwidth!
>No other company gives more support or power for your dedicated server
>http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/

-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb:
Dedicated Hosting for just $79/mo with 500 GB of bandwidth!
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/

Received on 2003-04-08