Parent

Included Modules

Class/Module Index [+]

Quicksearch

Excon::Socket

Attributes

data[RW]
remote_ip[R]

Public Class Methods

new(data = {}) click to toggle source
# File lib/excon/socket.rb, line 23
def initialize(data = {})
  @data = data
  @nonblock = data[:nonblock]
  @read_buffer = ''
  @eof = false
  connect
end

Public Instance Methods

legacy_readline() click to toggle source
# File lib/excon/socket.rb, line 66
def legacy_readline
  begin
    Timeout.timeout(@data[:read_timeout]) do
      @socket.readline
    end
  rescue Timeout::Error
    raise Excon::Errors::Timeout.new('read timeout reached')
  end
end
local_address() click to toggle source
# File lib/excon/socket.rb, line 84
def local_address
  unpacked_sockaddr[1]
end
local_port() click to toggle source
# File lib/excon/socket.rb, line 88
def local_port
  unpacked_sockaddr[0]
end
params() click to toggle source
# File lib/excon/socket.rb, line 9
def params
  Excon.display_warning('Excon::Socket#params is deprecated use Excon::Socket#data instead.')
  @data
end
params=(new_params) click to toggle source
# File lib/excon/socket.rb, line 14
def params=(new_params)
  Excon.display_warning('Excon::Socket#params= is deprecated use Excon::Socket#data= instead.')
  @data = new_params
end
read(max_length = nil) click to toggle source
# File lib/excon/socket.rb, line 31
def read(max_length = nil)
  if @eof
    return max_length ? nil : ''
  elsif @nonblock
    read_nonblock(max_length)
  else
    read_block(max_length)
  end
end
readline() click to toggle source
# File lib/excon/socket.rb, line 41
def readline
  return legacy_readline if RUBY_VERSION.to_f <= 1.8_7
  buffer = ''
  begin
    buffer << @socket.read_nonblock(1) while buffer[-1] != "\n"
    buffer
  rescue Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable 
    if timeout_reached('read')
      raise_timeout_error('read')
    else
      retry
    end
  rescue OpenSSL::SSL::SSLError => e
    if e.message == 'read would block'
      if timeout_reached('read')
        raise_timeout_error('read')
      else
        retry
      end
    else
      raise(error)
    end
  end
end
write(data) click to toggle source
# File lib/excon/socket.rb, line 76
def write(data)
  if @nonblock
    write_nonblock(data)
  else
    write_block(data)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.