Class: GQTP::Connection::Synchronous::Server

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Server

Returns a new instance of Server.



85
86
87
88
89
90
# File 'lib/gqtp/connection/synchronous.rb', line 85

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

Instance Attribute Details

#addressObject

Returns the value of attribute address.



84
85
86
# File 'lib/gqtp/connection/synchronous.rb', line 84

def address
  @address
end

#portObject

Returns the value of attribute port.



84
85
86
# File 'lib/gqtp/connection/synchronous.rb', line 84

def port
  @port
end

Instance Method Details

#runObject



92
93
94
95
96
97
98
99
100
# File 'lib/gqtp/connection/synchronous.rb', line 92

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

#shutdownObject



102
103
104
# File 'lib/gqtp/connection/synchronous.rb', line 102

def shutdown
  @server.shutdown
end