Class: Rev::Listener
Overview
Listeners wait for incoming connections. When a listener receives a connection it fires the on_connection event with the newly accepted socket as a parameter.
Direct Known Subclasses
Instance Method Summary collapse
-
#close ⇒ Object
Close the listener.
-
#fileno ⇒ Object
Returns an integer representing the underlying numeric file descriptor.
-
#initialize(listen_socket) ⇒ Listener
constructor
A new instance of Listener.
-
#on_connection(socket) ⇒ Object
Called whenever the server receives a new connection.
Methods inherited from IOWatcher
#attach, #detach, #disable, #enable, #on_writable
Methods included from Meta
#event_callback, #watcher_delegate
Methods inherited from Watcher
#attach, #attached?, #detach, #disable, #enable, #enabled?, #evloop
Constructor Details
#initialize(listen_socket) ⇒ Listener
Returns a new instance of Listener.
14 15 16 17 |
# File 'lib/rev/listener.rb', line 14 def initialize(listen_socket) @listen_socket = listen_socket super(@listen_socket) end |
Instance Method Details
#close ⇒ Object
Close the listener
25 26 27 28 |
# File 'lib/rev/listener.rb', line 25 def close detach if attached? @listen_socket.close end |
#fileno ⇒ Object
Returns an integer representing the underlying numeric file descriptor
20 21 22 |
# File 'lib/rev/listener.rb', line 20 def fileno @listen_socket.fileno end |
#on_connection(socket) ⇒ Object
Called whenever the server receives a new connection
31 |
# File 'lib/rev/listener.rb', line 31 def on_connection(socket); end |