Class: GQTP::Backend::Synchronous::Server
- Inherits:
-
Object
- Object
- GQTP::Backend::Synchronous::Server
- Defined in:
- lib/gqtp/backend/synchronous.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
- #shutdown ⇒ Object
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 = @host = [:host] || "0.0.0.0" @port = [:port] || 10043 @backlog = [:backlog] || 128 end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
88 89 90 |
# File 'lib/gqtp/backend/synchronous.rb', line 88 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
88 89 90 |
# File 'lib/gqtp/backend/synchronous.rb', line 88 def port @port end |
Instance Method Details
#run ⇒ Object
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 |
#shutdown ⇒ Object
106 107 108 |
# File 'lib/gqtp/backend/synchronous.rb', line 106 def shutdown @server.shutdown end |