Reading bytes and blocking

I come across this method:

read(n=nil, buffer=nil) read n bytes (or fewer, if EOF is reached),
blocking if necessary, until the bytes are ready.

What does it mean “blocking if necessary”? Blocking what?

On 30 October 2012 16:20, John M. [email protected] wrote:

I come across this method:

read(n=nil, buffer=nil) read n bytes (or fewer, if EOF is reached),
blocking if necessary, until the bytes are ready.

What does it mean “blocking if necessary”? Blocking what?

It means that if it is reading from a keyboard for example it will
wait (block) for data to be input if there is nothing available. A
non-blocking read will just pick up whatever data is available and
immediately return.

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs