Class: Server
- Inherits:
-
Object
- Object
- Server
- Includes:
- Messenger, Selectable
- Defined in:
- lib/socketeer/server.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
Attributes included from Messenger
Instance Method Summary collapse
- #cycle ⇒ Object
-
#initialize(host = 'localhost', port = 3123, handler = nil) ⇒ Server
constructor
A new instance of Server.
Methods included from Messenger
Methods included from Selectable
Constructor Details
#initialize(host = 'localhost', port = 3123, handler = nil) ⇒ Server
Returns a new instance of Server.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/socketeer/server.rb', line 16 def initialize host='localhost', port=3123, handler=nil @Handler = handler @host = host @port = port @connections = {} puts "BINDING: #{host}:#{port}" @tcp_server = TCPServer.new host, port register_monitor @tcp_server, :r do |monitor| handle_socket_connect @tcp_server.accept end end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
14 15 16 |
# File 'lib/socketeer/server.rb', line 14 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
14 15 16 |
# File 'lib/socketeer/server.rb', line 14 def port @port end |
Instance Method Details
#cycle ⇒ Object
30 31 32 33 34 35 |
# File 'lib/socketeer/server.rb', line 30 def cycle cycle_selector cycle_connection_queues cycle_inbound cycle_handlers end |