Class: RightSpeed::Listener::SimpleListener
- Inherits:
-
Object
- Object
- RightSpeed::Listener::SimpleListener
- Defined in:
- lib/right_speed/listener.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#sock ⇒ Object
readonly
Returns the value of attribute sock.
Instance Method Summary collapse
-
#initialize(host, port, backlog) ⇒ SimpleListener
constructor
A new instance of SimpleListener.
- #run ⇒ Object
- #stop ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize(host, port, backlog) ⇒ SimpleListener
Returns a new instance of SimpleListener.
21 22 23 24 25 26 |
# File 'lib/right_speed/listener.rb', line 21 def initialize(host, port, backlog) @host = host @port = port @backlog = backlog @sock = nil end |
Instance Attribute Details
#sock ⇒ Object (readonly)
Returns the value of attribute sock.
19 20 21 |
# File 'lib/right_speed/listener.rb', line 19 def sock @sock end |
Instance Method Details
#run ⇒ Object
28 29 30 31 32 33 |
# File 'lib/right_speed/listener.rb', line 28 def run @running = true @sock = TCPServer.open(@host, @port) @sock.listen(@backlog) if @backlog @sock end |
#stop ⇒ Object
39 40 41 42 43 44 |
# File 'lib/right_speed/listener.rb', line 39 def stop @running = false if @sock @sock.close rescue nil end end |
#wait ⇒ Object
35 36 37 |
# File 'lib/right_speed/listener.rb', line 35 def wait # do nothing end |