Class: Selenium::WebDriver::PortProber
Relationships & Source Files | |
Inherits: | Object |
Defined in: | rb/lib/selenium/webdriver/common/port_prober.rb |
Constant Summary
-
IGNORED_ERRORS =
# File 'rb/lib/selenium/webdriver/common/port_prober.rb', line 28[Errno::EADDRNOTAVAIL, Errno::EAFNOSUPPORT].tap { |arr| arr << Errno::EBADF if Platform.cygwin? arr << Errno::EACCES if Platform.windows? }.freeze
Class Method Summary
Class Method Details
.above(port)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/port_prober.rb', line 23
def self.above(port) port += 1 until free? port port end
.free?(port) ⇒ Boolean
# File 'rb/lib/selenium/webdriver/common/port_prober.rb', line 33
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.})", id: :driver_service) # ignored - some machines appear unable to bind to some of their interfaces end true rescue SocketError, Errno::EADDRINUSE false end