Class: Thrift::ServerSocket
- Inherits:
-
BaseServerTransport
- Object
- BaseServerTransport
- Thrift::ServerSocket
- Defined in:
- lib/thrift/transport/server_socket.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#handle ⇒ Object
(also: #to_io)
readonly
Returns the value of attribute handle.
Instance Method Summary collapse
- #accept ⇒ Object
- #close ⇒ Object
- #closed? ⇒ Boolean
-
#initialize(host_or_port, port = nil) ⇒ ServerSocket
constructor
call-seq: initialize(host = nil, port).
- #listen ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(host_or_port, port = nil) ⇒ ServerSocket
call-seq: initialize(host = nil, port)
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/thrift/transport/server_socket.rb', line 26 def initialize(host_or_port, port = nil) if port @host = host_or_port @port = port else @host = nil @port = host_or_port end @handle = nil end |
Instance Attribute Details
#handle ⇒ Object (readonly) Also known as: to_io
Returns the value of attribute handle.
37 38 39 |
# File 'lib/thrift/transport/server_socket.rb', line 37 def handle @handle end |
Instance Method Details
#accept ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/thrift/transport/server_socket.rb', line 43 def accept unless @handle.nil? sock = @handle.accept trans = Socket.new trans.handle = sock trans end end |
#close ⇒ Object
52 53 54 55 |
# File 'lib/thrift/transport/server_socket.rb', line 52 def close @handle.close unless @handle.nil? or @handle.closed? @handle = nil end |
#closed? ⇒ Boolean
57 58 59 |
# File 'lib/thrift/transport/server_socket.rb', line 57 def closed? @handle.nil? or @handle.closed? end |
#listen ⇒ Object
39 40 41 |
# File 'lib/thrift/transport/server_socket.rb', line 39 def listen @handle = TCPServer.new(@host, @port) end |
#to_s ⇒ Object
63 64 65 |
# File 'lib/thrift/transport/server_socket.rb', line 63 def to_s "socket(#{@host}:#{@port})" end |