Class: Rev::Listener

Inherits:
IOWatcher show all
Defined in:
lib/rev/listener.rb

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

Server, TCPListener, UNIXListener

Instance Method Summary collapse

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

#closeObject

Close the listener



25
26
27
28
# File 'lib/rev/listener.rb', line 25

def close
  detach if attached?
  @listen_socket.close
end

#filenoObject

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