class Async::IO::TCPServer

Asynchronous TCP server wrappper.

Public Class Methods

new(*args) click to toggle source
Calls superclass method Async::IO::TCPSocket::new
# File lib/async/io/tcp_socket.rb, line 86
def initialize(*args)
        if args.first.is_a? ::TCPServer
                super(args.first)
        else
                # We assume this operation doesn't block (for long):
                super(::TCPServer.new(*args))
        end
end

Public Instance Methods

accept(timeout: nil, task: Task.current) { |wrapper, address| ... } click to toggle source
# File lib/async/io/tcp_socket.rb, line 95
def accept(timeout: nil, task: Task.current)
        peer, address = async_send(:accept_nonblock, timeout: timeout)
        
        wrapper = TCPSocket.new(peer)
        
        wrapper.timeout = self.timeout
        
        return wrapper, address unless block_given?
        
        begin
                yield wrapper, address
        ensure
                wrapper.close
        end
end
Also aliased as: accept_nonblock, sysaccept
accept_nonblock(timeout: nil, task: Task.current)
Alias for: accept
sysaccept(timeout: nil, task: Task.current)
Alias for: accept