class Thrift::ServerSocket
Attributes
Public Class Methods
Source
# File lib/thrift/transport/server_socket.rb 27 def initialize(host_or_port, port = nil, client_timeout: DEFAULT_CLIENT_TIMEOUT) 28 if port 29 @host = host_or_port 30 @port = port 31 else 32 @host = nil 33 @port = host_or_port 34 end 35 @client_timeout = client_timeout 36 @handle = nil 37 end
Public Instance Methods
Source
# File lib/thrift/transport/server_socket.rb 45 def accept 46 unless @handle.nil? 47 sock = @handle.accept 48 sock.setsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1) 49 trans = Socket.new 50 trans.timeout = @client_timeout 51 trans.handle = sock 52 trans 53 end 54 end
Source
# File lib/thrift/transport/server_socket.rb 56 def close 57 @handle.close unless @handle.nil? or @handle.closed? 58 @handle = nil 59 end
Source
# File lib/thrift/transport/server_socket.rb 61 def closed? 62 @handle.nil? or @handle.closed? 63 end
Source
# File lib/thrift/transport/server_socket.rb 41 def listen 42 @handle = TCPServer.new(@host, @port) 43 end
Source
# File lib/thrift/transport/server_socket.rb 65 def to_io 66 @handle&.to_io || raise(IOError, "closed stream") 67 end
Source
# File lib/thrift/transport/server_socket.rb 69 def to_s 70 "socket(#{@host}:#{@port})" 71 end