In article <17b6c68ca7a0c35209ac51f136506734 / ruby-forum.com>,
  Luke Burton <luke / burton.echidna.id.au> writes:

> I tested this earlier ... but my version of Ruby doesn't have 
> read_nonblock, unfortunately. I haven't had a chance to pull down 1.8.5 
> and re-test.

This should work with 1.8.2.

    def rbuf_fill
      if IO.select([@io], nil, nil, @read_timeout)
        @rbuf << @io.sysread(16384)
      else
        raise Timeout::TimeoutError
      end
    end

The enlarging buffer size should work well until in-kernel
TCP buffer is large enough to store data receiving between
successive rbuf_fill.

If the in-kernel buffer is not large enough, the overhead
should be reduced.  I think timeout() is the first candidate
to remove.
-- 
Tanaka Akira