Class: Selenium::WebDriver::PortProber

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/webdriver/common/port_prober.rb

Class Method Summary collapse

Class Method Details

.above(port) ⇒ Object



4
5
6
7
# File 'lib/selenium/webdriver/common/port_prober.rb', line 4

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

.free?(port) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
# File 'lib/selenium/webdriver/common/port_prober.rb', line 17

def self.free?(port)
  TCPServer.new(Platform.localhost, port).close
  true
rescue SocketError, Errno::EADDRINUSE
  false
end

.randomObject



9
10
11
12
13
14
15
# File 'lib/selenium/webdriver/common/port_prober.rb', line 9

def self.random
  server = TCPServer.new(Platform.localhost, 0)
  port   = server.addr[1]
  server.close
  
  port
end