--Multipart_Sun_Mar__2_18:27:38_2003-1
Content-Type: text/plain; charset=US-ASCII

Hi,

At Fri, 28 Feb 2003 01:12:07 +0900,
Seth Kurtzberg wrote:
> This is with 1.8 CVS head on linux kernel 2.4.20.

EAGAIN/EWOULDBLOCK should be handled in 1.8, IO#read with no
arguments for non-blocking IO doesn't wait unreceived data.

$ ruby server.rb foo &
[1] 13697

$ ruby client.rb foo
""

$ ruby client.rb foo 3
"hello,"

$ ruby client.rb foo 5
"hello, world"


--Multipart_Sun_Mar__2_18:27:38_2003-1
Content-Type: text/x-ruby; charset=US-ASCII
Content-Disposition: attachment; filename="server.rb"
Content-Transfer-Encoding: 7bit

#! /usr/bin/ruby
require 'socket'
PATH  RGV.shift
s  NIXServer.open(PATH)
begin
  loop do
    Thread.new(s.accept) do |t|
      sleep 1
      t.write "hello,"
      sleep 2
      t.write " world"
    end
  end
ensure
  s.close
  File.unlink(PATH)
end

--Multipart_Sun_Mar__2_18:27:38_2003-1
Content-Type: text/x-ruby; charset=US-ASCII
Content-Disposition: attachment; filename="client.rb"
Content-Transfer-Encoding: 7bit

#! /usr/bin/ruby
require 'socket'
require 'io/nonblock'

PATH  RGV.shift
WAIT  RGV.shift.to_i
s  NIXSocket.new(PATH)
p s.nonblock {sleep WAIT; s.read}

--Multipart_Sun_Mar__2_18:27:38_2003-1
Content-Type: text/x-ruby; charset=US-ASCII
Content-Disposition: attachment; filename="io/nonblock.rb"
Content-Transfer-Encoding: 7bit

require "fcntl"
class IO
  def nonblock?
    (fcntl(Fcntl::F_GETFL) & File::NONBLOCK) ! 
  end

  def nonblockb)
    f  cntl(Fcntl::F_GETFL)
    if nb
      f | ile::NONBLOCK
    else
      f & File::NONBLOCK
    end
    fcntl(Fcntl::F_SETFL, f)
  end

  def nonblock(nb  rue)
    nb, self.nonblock  onblock?, nb
    yield
  ensure
    self.nonblock  b
  end
end

--Multipart_Sun_Mar__2_18:27:38_2003-1
Content-Type: text/plain; charset=US-ASCII


-- 
Nobu Nakada

--Multipart_Sun_Mar__2_18:27:38_2003-1--