#2180 Blocking InStream Reads

SlimerDude Sun 4 Aug 2013

sys::InStream.readBufFully says:

Block until exactly n bytes have been read...

Which is fine, but what of the other read methods such as sys::InStream.readU4? The docs say:

Throw IOErr on error or if the end of stream is reached before four bytes can be read.

But say nothing about blocking until the 4 bytes are available?

I guess I'm asking if:

in.readBufFully(null, 4).readU4

which read 4 bytes (blocking if unavailable) into a Buf is the same as

in.readU4

brian Sun 4 Aug 2013

Pretty much everything is blocking if the stream isn't closed and no bytes are available. Low level reads like read return null when at end of stream, but data reads that expect multiple bytes like readU4 raise exception when 4 bytes aren't available before end of stream. But they do block until those bytes are available.

SlimerDude Sun 4 Aug 2013

Thanks.

I guess I was looking for clarification about what end of stream meant, either

  • no bytes currently available, or
  • stream closed.

Cheers.

brian Sun 4 Aug 2013

It means stream closed

Login or Signup to reply.