Skip to content

Instantly share code, notes, and snippets.

@lann
Created September 28, 2015 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lann/8e3d19a7dfe618dfadc4 to your computer and use it in GitHub Desktop.
Save lann/8e3d19a7dfe618dfadc4 to your computer and use it in GitHub Desktop.
require 'tcp_timeout'
server = 'stackoverflow.com'
begin
socket = TCPTimeout::TCPSocket.new(server, 80, read_timeout: 1)
socket.read(100)
rescue TCPTimeout::SocketTimeout => e
puts "[!] #{server} Timeout"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment