Sha256: 5083c32373cc3b72c65cc144813359be90d5d6388a94e36872d5f57cbd4b97ca

Contents?: true

Size: 656 Bytes

Versions: 17

Compression:

Stored size: 656 Bytes

Contents

require 'timeout'
require 'socket'

class TCPSocket
  
  def self.wait_for_service(options)
    verbose_wait until listening_service?(options)
  end
  
  def self.wait_for_service_termination(options)
    verbose_wait while listening_service?(options)
  end

  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

  def self.verbose_wait
    puts ".\n"
    sleep 2
  end

end

Version data entries

17 entries across 17 versions & 4 rubygems

Version Path
selenium-selenese-1.1.13 lib/tcp_socket_extension.rb
selenium-selenese-1.1.12 lib/tcp_socket_extension.rb
selenium-selenese-1.1.11 lib/tcp_socket_extension.rb
selenium-selenese-1.1.10 lib/tcp_socket_extension.rb
selenium-selenese-1.1.6 lib/tcp_socket_extension.rb
selenium-selenese-1.1.4 lib/tcp_socket_extension.rb
selenium-selenese-1.1.3 lib/tcp_socket_extension.rb
warnold-selenium-client-1.2.19 lib/tcp_socket_extension.rb
selenium-rspec-dsl-1.0.2 vendor/selenium-client-1.2.17/lib/tcp_socket_extension.rb
selenium-client-1.2.18 lib/tcp_socket_extension.rb
selenium-client-1.2.17 lib/tcp_socket_extension.rb
selenium-client-1.2.16 lib/tcp_socket_extension.rb
selenium-client-1.2.13 lib/tcp_socket_extension.rb
selenium-client-1.2.12 lib/tcp_socket_extension.rb
selenium-client-1.2.15 lib/tcp_socket_extension.rb
selenium-client-1.2.14 lib/tcp_socket_extension.rb
selenium-client-1.2.11 lib/tcp_socket_extension.rb