A listener for incoming connections.
Create with {Container#listen} or {Container#listen_io}. To control the handler and connection options applied to incoming connections, pass a {ListenerHandler} on creation.
@return [Condition] The error condition if there is one
@return [Container] The listener's container
# File lib/core/listener.rb, line 88 def initialize(io, container) @io = io @container = container @closing = nil end
Initiate closing the the listener. It will not be fully {#closed?} until its {Handler#on_close} is called by the {Container} @param error [Condition] Optional error condition.
# File lib/core/listener.rb, line 69 def close(error=nil) return if closed? || @closing @closing = true @condition ||= Condition.convert error @io.close_read rescue nil # Force Container IO.select to wake with listener readable. nil end
True if the listening socket is fully closed
# File lib/core/listener.rb, line 84 def closed?() @io.closed?; end
Get the IP port used by the listener
# File lib/core/listener.rb, line 81 def port() to_io.addr[1]; end
Get the {IO} server socket used by the listener
# File lib/core/listener.rb, line 78 def to_io() @io; end