w00d
w00d

Reputation: 5596

Ruby IO#write_nonblock when to use?

It's simple for read_nonblock since the other end might not send anything yet and we will be blocked until some data is available. But I can't think of a case that write() is blocked. Can someone give me an example, sample code is highly appreciated.

Upvotes: 0

Views: 294

Answers (1)

w00d
w00d

Reputation: 5596

Found the answer... Block if write()-ing a huge data that bigger than the system buffer (~2MB?), and the other end is not recv()-ing.

Also possible to block when writing to disk if the disk is busy.

p/s: credit goes to #ruby-lang @freenode :)

Upvotes: 3

Related Questions