Class: Thrift::UNIXServerSocket

Inherits:
BaseServerTransport show all
Defined in:
lib/thrift/transport/unix_server_socket.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ UNIXServerSocket

Returns a new instance of UNIXServerSocket.



25
26
27
28
# File 'lib/thrift/transport/unix_server_socket.rb', line 25

def initialize(path)
  @path = path
  @handle = nil
end

Instance Attribute Details

#handleObject Also known as: to_io

Returns the value of attribute handle.



30
31
32
# File 'lib/thrift/transport/unix_server_socket.rb', line 30

def handle
  @handle
end

Instance Method Details

#acceptObject



36
37
38
39
40
41
42
43
# File 'lib/thrift/transport/unix_server_socket.rb', line 36

def accept
  unless @handle.nil?
    sock = @handle.accept
    trans = UNIXSocket.new(nil)
    trans.handle = sock
    trans
  end
end

#closeObject



45
46
47
48
49
50
51
52
# File 'lib/thrift/transport/unix_server_socket.rb', line 45

def close
  if @handle
    @handle.close unless @handle.closed?
    @handle = nil
    # UNIXServer doesn't delete the socket file, so we have to do it ourselves
    File.delete(@path)
  end
end

#closed?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/thrift/transport/unix_server_socket.rb', line 54

def closed?
  @handle.nil? or @handle.closed?
end

#listenObject



32
33
34
# File 'lib/thrift/transport/unix_server_socket.rb', line 32

def listen
  @handle = ::UNIXServer.new(@path)
end

#to_sObject



60
61
62
# File 'lib/thrift/transport/unix_server_socket.rb', line 60

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