lib/mongo/socket.rb
def read(length, timeout: nil)
      map_exceptions do
        data = read_from_socket(length, timeout: timeout)
        unless (data.length > 0 || length == 0)
          raise IOError, "Expected to read > 0 bytes but read 0 bytes"
        end
        while data.length < length
          chunk = read_from_socket(length - data.length, timeout: timeout)
          unless (chunk.length > 0 || length == 0)
            raise IOError, "Expected to read > 0 bytes but read 0 bytes"
          end
          data << chunk
        end
        data
      end
    end
# Will read all data from the socket for the provided number of bytes.
# If no data is returned, an exception will be raised.
#
# @example Read all the requested data from the socket.
#   socket.read(4096)
#
# @param [ Integer ] length The number of bytes to read.
# @param [ Numeric ] timeout The timeout to use for each chunk read.
#
# @raise [ Mongo::SocketError ] If not all data is returned.
#
# @return [ Object ] The data from the socket.
#
# @since 2.0.0
Will read all data from the socket for the provided number of bytes.
If no data is returned, an exception will be raised.
Will read all data from the socket for the provided number of bytes . If no data is returned an exception will be raised .
def read(length, timeout: nil)
      map_exceptions do
        data = read_from_socket(length, timeout: timeout)
        unless (data.length > 0 || length == 0)
          raise IOError, "Expected to read > 0 bytes but read 0 bytes"
        end
        while data.length < length
          chunk = read_from_socket(length - data.length, timeout: timeout)
          unless (chunk.length > 0 || length == 0)
            raise IOError, "Expected to read > 0 bytes but read 0 bytes"
          end
          data << chunk
        end
        data
      end
    end
def read ( length , timeout : nil ) map_exceptions do data = read_from_socket ( length , timeout : timeout ) unless ( data . length > 0 || length == 0 ) raise IOError , "Expected to read > 0 bytes but read 0 bytes" end while data . length < length chunk = read_from_socket ( length - data . length , timeout : timeout ) unless ( chunk . length > 0 || length == 0 ) raise IOError , "Expected to read > 0 bytes but read 0 bytes" end data << chunk end data end end
Will read all data from the socket for the provided number of bytes.
Will read all data from the socket for the provided number of bytes .
The data from the socket.
The data from the socket .
 Object 
[ Mongo::SocketError ] If not all data is returned.
[ Mongo :: SocketError ] If not all data is returned .
length
timeout
timeout The timeout to use for each chunk read.
timeout The timeout to use for each chunk read .
example
Read all the requested data from the socket.
Read all the requested data from the socket .
since
None