class Async::DNS::StreamHandler
Public Instance Methods
handle_connection(socket)
click to toggle source
# File lib/async/dns/handler.rb, line 117 def handle_connection(socket) transport = Transport.new(socket) while input_data = transport.read_chunk response = process_query(input_data, remote_address: socket.remote_address) length = transport.write_message(response) @logger.debug "<#{response.id}> Wrote #{length} bytes via TCP..." end rescue EOFError => error @logger.warn "<> Error: TCP session ended prematurely!" rescue Errno::ECONNRESET => error @logger.warn "<> Error: TCP connection reset by peer!" rescue Errno::EPIPE @logger.warn "<> Error: TCP session failed due to broken pipe!" rescue DecodeError @logger.warn "<> Error: Could not decode incoming TCP data!" end
run(backlog = Socket::SOMAXCONN)
click to toggle source
# File lib/async/dns/handler.rb, line 109 def run(backlog = Socket::SOMAXCONN) @socket.listen(backlog) @socket.accept_each do |client, address| handle_connection(client) end end