curl-library
Re: non-blocking read function
Date: Wed, 31 Oct 2007 02:19:05 +0000
Georg Lippitsch wrote:
> Am Dienstag, 30. Oktober 2007 22:28 schrieb Daniel Stenberg:
>
> > Why 0? Why not just a CURL_MAGIC_READ_IS_NOW_PAUSED define, that certainly
> > won't cause any backwards compatibility issues?
>
> Because 0 is IMO the most logical approach.
> As documentation says: "Your function must return the actual number of bytes
> that you stored in that memory area"
> So, if I don't store any bytes in that memory area right now, consequently 0
> is the correct value to return.
You might think so, but it doesn't seem to be popular in modern APIs.
(Very old unixes did this, and still can do for terminal devices, but
it's a problem because 0 also means EOF on them.)
POSIX API uses EAGAIN for "didn't read/write anything but try again
later, not EOF". Some unixes use EWOULDBLOCK. Windows uses another
error code, and I think Java and .NET use an exception.
So it would be fairly consistent for libcurl to use a special code for
"didn't read/write anything but try again later, not EOF".
-- Jamie
Received on 2007-10-31