Class: Thrift::UNIXSocket

Inherits:
Socket show all
Defined in:
lib/thrift/transport/unix_socket.rb

Instance Attribute Summary

Attributes inherited from Socket

#handle, #timeout

Instance Method Summary collapse

Methods inherited from Socket

#close, #open?, #read, #write

Methods inherited from BaseTransport

#close, #flush, #open?, #read, #read_all, #read_byte, #read_into_buffer, #write

Constructor Details

#initialize(path, timeout = nil) ⇒ UNIXSocket

Returns a new instance of UNIXSocket.



25
26
27
28
29
30
# File 'lib/thrift/transport/unix_socket.rb', line 25

def initialize(path, timeout=nil)
  @path = path
  @timeout = timeout
  @desc = @path # for read()'s error
  @handle = nil
end

Instance Method Details

#openObject



32
33
34
35
36
37
38
# File 'lib/thrift/transport/unix_socket.rb', line 32

def open
  begin
    @handle = ::UNIXSocket.new(@path)
  rescue StandardError
    raise TransportException.new(TransportException::NOT_OPEN, "Could not open UNIX socket at #{@path}")
  end
end

#to_sObject



40
41
42
# File 'lib/thrift/transport/unix_socket.rb', line 40

def to_s
  "domain(#{@path})"
end