79: def next_packet(mode=:nonblock)
80: case mode
81: when :nonblock then
82: fill if available_for_read?
83: poll_next_packet
84:
85: when :block then
86: loop do
87: packet = poll_next_packet
88: return packet if packet
89:
90: loop do
91: result = Net::SSH::Compat.io_select([self]) or next
92: break if result.first.any?
93: end
94:
95: if fill <= 0
96: raise Net::SSH::Disconnect, "connection closed by remote host"
97: end
98: end
99:
100: else
101: raise ArgumentError, "expected :block or :nonblock, got #{mode.inspect}"
102: end
103: end