module Dalli::Server::KSocket::InstanceMethods

Public Instance Methods

read_available() click to toggle source
# File lib/dalli/socket.rb, line 115
def read_available
  value = String.new('')
  while true
    begin
      value << read_nonblock(8196)
    rescue Errno::EAGAIN, Errno::EWOULDBLOCK
      break
    end
  end
  value
end
readfull(count) click to toggle source
# File lib/dalli/socket.rb, line 97
def readfull(count)
  value = String.new('')
  begin
    while true
      value << read_nonblock(count - value.bytesize)
      break if value.bytesize == count
    end
  rescue Errno::EAGAIN, Errno::EWOULDBLOCK
    if IO.select([self], nil, nil, options[:socket_timeout])
      retry
    else
      safe_options = options.reject{|k,v| [:username, :password].include? k}
      raise Timeout::Error, "IO timeout: #{safe_options.inspect}"
    end
  end
  value
end