An IO Streams Library
Chris Wright via Digitalmars-d
digitalmars-d at puremagic.com
Tue Feb 9 09:32:10 PST 2016
On Tue, 09 Feb 2016 09:45:03 +0000, Kagamin wrote:
> On Monday, 8 February 2016 at 20:21:31 UTC, Jason White wrote:
>> Reads and writes are not guaranteed to fill/write the entire buffer you
>> throw at it. This is what readExactly/writeExactly are for. Those will
>> throw an exception if the entire read/write cannot be done.
>
> You mean posix non-blocking IO?
No, Posix non-blocking IO will fill a buffer with all data that is
currently available and tell you the number of bytes it managed to give
you. And then it will set errno to EAGAIN.
readExactly will either fill the entire buffer or throw an exception
saying that it was unable to do so.
It's using Posix functions underneath, so if it repeatedly calls them
until it's sent the whole buffer (assuming EAGAIN is set), that saves me
work sometimes (but I think phobos does that already).
But if it throws an exception even when errno is set to EAGAIN, that
would be useful for writing to a file atomically.
More information about the Digitalmars-d
mailing list