class Selenium::WebDriver::PortProber

def self.above(port)

def self.above(port)
  port += 1 until free? port
  port
end

def self.free?(port)

def self.free?(port)
  Platform.interfaces.each do |host|
    TCPServer.new(host, port).close
  rescue *IGNORED_ERRORS => e
    WebDriver.logger.debug("port prober could not bind to #{host}:#{port} (#{e.message})", id: :driver_service)
    # ignored - some machines appear unable to bind to some of their interfaces
  end
  true
rescue SocketError, Errno::EADDRINUSE
  false
end