Class: GQTP::Connection::Synchronous::Server
- Inherits:
-
Object
- Object
- GQTP::Connection::Synchronous::Server
- Defined in:
- lib/gqtp/connection/synchronous.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#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.
85 86 87 88 89 90 |
# File 'lib/gqtp/connection/synchronous.rb', line 85 def initialize(={}) @options = @address = [:address] || "0.0.0.0" @port = [:port] || 10041 @backlog = [:backlog] || 128 end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
84 85 86 |
# File 'lib/gqtp/connection/synchronous.rb', line 84 def address @address end |
#port ⇒ Object
Returns the value of attribute port.
84 85 86 |
# File 'lib/gqtp/connection/synchronous.rb', line 84 def port @port end |
Instance Method Details
#run ⇒ Object
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 |
#shutdown ⇒ Object
102 103 104 |
# File 'lib/gqtp/connection/synchronous.rb', line 102 def shutdown @server.shutdown end |