In article <84D5D729-3674-4084-A092-2359932E2FF4 / grayproductions.net>,
  James Edward Gray II <james / grayproductions.net> writes:

> Non-blocking IO is another solution.

O_NONBLOCK is not always applicable.

* read from socket: works well by default. (O_NONBLOCK is not required.)
  (UDP packet with wrong checksum on Linux 2.6 is an exception.)
* write to socket: O_NONBLOCK is required.
* read from pipe, console (and devices): works well by default on Unix.
  may not work on other platforms.
* write to pipe, console (and devices): O_NONBLOCK is required on Unix. 
  may not work on other platforms.
* read from file: AIO or native thread is required.  Ruby doesn't support yet.
* write to file: AIO or native thread is required.  Ruby doesn't support yet.
* connect: works well by default. (Ruby use O_NONBLOCK internally.)
* accept: works well by default. (Old BSD platform require O_NONBLOCK?)

Note that Ruby 1.8.2 or former may lost data if O_NONBLOCK is set.
It is fixed by Ruby 1.9.  Ruby 1.8.3 can avoid the problem by
IO#sync=true which is default for sockets.

Also note that some methods behave differently when O_NONBLOCK is
set.  So O_NONBLOCK should be used carefully.  I think O_NONBLOCK can
be usable more easily if Ruby provides blocking methods and
nonblocking methods.  I proposed a method for nonblocking connect on
ruby-dev but matz doesn't accept because its name is not good enough,
though.
-- 
Tanaka Akira