5000 @selector.register Fiber.current, io Fiber.yield io.write_nonblock "response" @selector.register Fiber.current, io Fiber.yield end class Scheduler def io_wait(io, events, timeout) @selector.register Fiber.current, io, events end end Fiber.set_scheduler(Scheduler.new) Fiber. schedule do message = io.read 5000 io.write "response" end