method
create_listeners
create_listeners(address, port, logger=nil)
private
Hide source
# File lib/webrick/utils.rb, line 59 def create_listeners(address, port, logger=nil) unless port raise ArgumentError, "must specify port" end res = Socket::getaddrinfo(address, port, Socket::AF_UNSPEC, # address family Socket::SOCK_STREAM, # socket type 0, # protocol Socket::AI_PASSIVE) # flag last_error = nil sockets = [] res.each{|ai| begin logger.debug("TCPServer.new(#{ai[3]}, #{port})") if logger sock = TCPServer.new(ai[3], port) port = sock.addr[1] if port == 0 Utils::set_close_on_exec(sock) sockets << sock rescue => ex logger.warn("TCPServer Error: #{ex}") if logger last_error = ex end } raise last_error if sockets.empty? return sockets end