Skip to content

Instantly share code, notes, and snippets.

@briancain
Created November 6, 2019 22:38
Show Gist options
  • Save briancain/3d1f65faaa032d772df7957a833d873c to your computer and use it in GitHub Desktop.
Save briancain/3d1f65faaa032d772df7957a833d873c to your computer and use it in GitHub Desktop.
brian@localghost:vagrant-sandbox % ruby timeout.rb ±[●●][master]
The time: 5.000828619
require 'net/http'
HTTP_NETWORK_TEST_HOST = "www.google.com"
start = Time.now
begin
http = Net::HTTP.start(HTTP_NETWORK_TEST_HOST, '81', {read_timeout: 5, open_timeout: 5})
rescue Net::OpenTimeout => e
end
finish = Time.now
puts "The time: #{finish - start}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment