Path: blob/master/lib/rex/post/channel/stream_abstraction.rb
19721 views
# -*- coding: binary -*-12require 'rex/io/stream_abstraction'34module Rex5module Post6module Channel7module StreamAbstraction8include Rex::IO::StreamAbstraction910#11# Read *length* bytes from the channel. If the operation times out, the data12# that was read will be returned or nil if no data was read.13#14def read(length = nil)15if closed?16raise IOError, 'Channel has been closed.', caller17end1819buf = ''20length = 65536 if length.nil?2122begin23buf << lsock.recv(length - buf.length) while buf.length < length24rescue StandardError25buf = nil if buf.empty?26end2728buf29end30end31end32end33end343536