class TCPSocket

Public Class Methods

listening_service?(options) click to toggle source
# File lib/tcp_socket_extension.rb, line 14
def self.listening_service?(options)
  Timeout::timeout(options[:timeout] || 20) do
    begin
      socket = TCPSocket.new(options[:host], options[:port])
      socket.close unless socket.nil?
      true
    rescue Errno::ECONNREFUSED, 
           Errno::EBADF           # Windows
      false
    end
  end
end
verbose_wait() click to toggle source
# File lib/tcp_socket_extension.rb, line 27
def self.verbose_wait
  puts ".\n"
  sleep 2
end
wait_for_service(options) click to toggle source
# File lib/tcp_socket_extension.rb, line 6
def self.wait_for_service(options)
  verbose_wait until listening_service?(options)
end
wait_for_service_termination(options) click to toggle source
# File lib/tcp_socket_extension.rb, line 10
def self.wait_for_service_termination(options)
  verbose_wait while listening_service?(options)
end