- rfds, = select([socket, $stdin])
- if rfds.delete(socket)
- line = socket.gets(\"\r\n\")
+ rfds, wfds, = select([socket, $stdin], wfds_in)
+ unless wfds.empty?
+ until buf.length <= " max-buffer-size "
+ i = buf.index(\"\\r\\n\")
+ break unless i
+ buf.slice!(0 .. i + 1)
+ end
+ begin
+ until buf.empty?
+ len = $stdout.syswrite(buf)
+ buf.slice!(0 .. len)
+ end
+ wfds_in = []
+ rescue Errno::EAGAIN
+ end
+ end
+ if rfds.include?(socket)
+ line = socket.gets(\"\\r\\n\")