Class: GQTP::Backend::Synchronous::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/gqtp/backend/synchronous.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Server

Returns a new instance of Server.



89
90
91
92
93
94
# File 'lib/gqtp/backend/synchronous.rb', line 89

def initialize(options={})
  @options = options
  @host = options[:host] || "0.0.0.0"
  @port = options[:port] || 10043
  @backlog = options[:backlog] || 128
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



88
89
90
# File 'lib/gqtp/backend/synchronous.rb', line 88

def host
  @host
end

#portObject

Returns the value of attribute port.



88
89
90
# File 'lib/gqtp/backend/synchronous.rb', line 88

def port
  @port
end

Instance Method Details

#runObject



96
97
98
99
100
101
102
103
104
# File 'lib/gqtp/backend/synchronous.rb', line 96

def run
  @server = TCPServer.new(@host, @port)
  @server.listen(@backlog)
  loop do
    client = @server.accept
    yield(IO.new(client))
  end
  Request.new(nil)
end

#shutdownObject



106
107
108
# File 'lib/gqtp/backend/synchronous.rb', line 106

def shutdown
  @server.shutdown
end