Sha256: 43c8e82b1b5b42e1622a14eb73c4b62220e891c1dca0c01f8d474f2270e2f115

Contents?: true

Size: 321 Bytes

Versions: 108

Compression:

Stored size: 321 Bytes

Contents

require 'timeout'
require 'socket'

module NetworkConnection
  def self.connect_to(host, port, timeout=10)
    Timeout.timeout(timeout) do
      TCPSocket.new(host, port)
    end
  end

  def self.is_network_available?
    begin
      self.connect_to("8.8.8.8", 53, 5)
      true
    rescue
      false
    end
  end
end

Version data entries

108 entries across 102 versions & 8 rubygems

Version Path
vagrant-unbundled-2.1.2.0 vendor/bundle/ruby/2.3.0/gems/webmock-2.3.2/spec/support/network_connection.rb
webmock-3.4.2 spec/support/network_connection.rb
vagrant-unbundled-2.1.1.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/spec/support/network_connection.rb
vagrant-unbundled-2.0.4.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/spec/support/network_connection.rb
webmock-3.4.1 spec/support/network_connection.rb
webmock-3.4.0 spec/support/network_connection.rb
vagrant-unbundled-2.0.3.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/spec/support/network_connection.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/support/network_connection.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/spec/support/network_connection.rb
webmock-3.3.0 spec/support/network_connection.rb
webmock-3.2.1 spec/support/network_connection.rb
webmock-3.2.0 spec/support/network_connection.rb
vagrant-unbundled-2.0.1.0 vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/spec/support/network_connection.rb
webmock-3.1.1 spec/support/network_connection.rb
webmock-3.1.0 spec/support/network_connection.rb
logstash-output-icinga-1.1.0 vendor/jruby/2.3.0/gems/webmock-2.3.2/spec/support/network_connection.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/webmock-2.3.2/spec/support/network_connection.rb
logstash-output-icinga-1.0.0 vendor/jruby/1.9/gems/webmock-2.3.2/spec/support/network_connection.rb
webmock-3.0.1 spec/support/network_connection.rb
webmock-3.0.0 spec/support/network_connection.rb