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