4 ms·
(You referenced the one byte read function, instead of the multi-byte function used in the OP.) The documentation does not answer how long it blocks. Blocking
by Perseids 13y ago
(You referenced the one byte read function, instead of the multi-byte function used in the OP.)
The documentation does not answer how long it blocks. Blocking when there is no input is completely ok in this use case as there is nothing better to do instead of waiting for input. The relevant question is how long it blocks after there is some input available for efficiency reasons.
- dvdkhlng 13y ago> there is nothing better to do instead of waiting for input. In case no more input is available it would be best to already output the data that have accumulated in buffer. Else in case the input program deadlocks you're never going to see the last (up to 8191) bytes output. This is what non-blocking I/O is for. With non-blocking I/O you first wait until your input channel becomes readable, then reading functions return as soon as the data available for read is exhausted.
- Perseids 13y agoYou are right but I was talking about the case when no input was there to be read since the call to `read` and also about this specific application: > Blocking when there is no input is completely ok in this use case as there is nothing better to do instead of waiting for input. (Emphasis is new.)
- dvdkhlng 13y agoYou're right, I overlooked the reference to the function reading a single byte.