Class: Thrift::UNIXServerSocket
- Inherits:
-
BaseServerTransport
- Object
- BaseServerTransport
- Thrift::UNIXServerSocket
- Defined in:
- lib/thrift/transport/unix_server_socket.rb
Instance Attribute Summary collapse
-
#handle ⇒ Object
(also: #to_io)
Returns the value of attribute handle.
Instance Method Summary collapse
- #accept ⇒ Object
- #close ⇒ Object
- #closed? ⇒ Boolean
-
#initialize(path) ⇒ UNIXServerSocket
constructor
A new instance of UNIXServerSocket.
- #listen ⇒ Object
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
#handle ⇒ Object 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
#accept ⇒ Object
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 |
#close ⇒ Object
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
54 55 56 |
# File 'lib/thrift/transport/unix_server_socket.rb', line 54 def closed? @handle.nil? or @handle.closed? end |
#listen ⇒ Object
32 33 34 |
# File 'lib/thrift/transport/unix_server_socket.rb', line 32 def listen @handle = ::UNIXServer.new(@path) end |