Module: Glint::Util
- Defined in:
- lib/glint/util.rb
Class Method Summary collapse
Class Method Details
.check_port(port) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/glint/util.rb', line 12 def self.check_port(port) begin socket = TCPSocket.open('127.0.0.1', port) socket.close return true rescue Errno::ECONNREFUSED return false end end |
.empty_port ⇒ Object
5 6 7 8 9 10 |
# File 'lib/glint/util.rb', line 5 def self.empty_port s = TCPServer.open(0) port = s.addr[1] s.close port end |
.wait_port(port) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/glint/util.rb', line 22 def self.wait_port(port) 100.times do |n| return true if check_port(port) sleep 0.1 end raise RuntimeError.new("Could not open the port: #{port}") end |