Async read an output stream but how many bytes ?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 31 06:48:46 PDT 2016


On 3/30/16 10:06 PM, Basile B. wrote:
> On Thursday, 31 March 2016 at 01:12:50 UTC, Adam D. Ruppe wrote:
>> On Thursday, 31 March 2016 at 00:50:16 UTC, Basile B. wrote:
>>> There should be a way to know how many bytes are available ?
>>
>> You are already using poll()... I'd just use read() directly on the
>> file number too. It will read as much as is available up to the max
>> size of the buffer, but if it can't fill it all, it just does what it
>> can and returns.
>
> It's probably the only way. I've also tried core.stdc.stdio.readf() in a
> loop and it was also reading until the process termination. So I'll go
> for a single readf operation on a ubyte[].

stdio.readf is buffered. It does not deal with async io properly I think.

-Steve



More information about the Digitalmars-d-learn mailing list