Class: Thrift::ServerSocket

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#handleObject (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

#acceptObject



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

#closeObject



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

Returns:

  • (Boolean)


57
58
59
# File 'lib/thrift/transport/server_socket.rb', line 57

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

#listenObject



39
40
41
# File 'lib/thrift/transport/server_socket.rb', line 39

def listen
  @handle = TCPServer.new(@host, @port)
end