def initialize io
@uuid = UuidGenerator.generate
@io = io
@last_activity = Reactor.instance.current_loop_time
if defined?(Fcntl::F_GETFL)
m = @io.fcntl(Fcntl::F_GETFL, 0)
@io.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK | m)
else
begin
s = Socket.for_fd(@io.fileno)
s.fcntl( Fcntl::F_SETFL, Fcntl::O_NONBLOCK )
rescue Errno::EINVAL, Errno::EBADF
warn "Serious error: unable to set descriptor non-blocking"
end
end
@close_scheduled = false
@close_requested = false
se = self; @io.instance_eval { @my_selectable = se }
Reactor.instance.add_selectable @io
end