Skip to content

Instantly share code, notes, and snippets.

@Fonsan
Created May 3, 2010 21:35
Show Gist options
  • Save Fonsan/388615 to your computer and use it in GitHub Desktop.
Save Fonsan/388615 to your computer and use it in GitHub Desktop.
require 'socket'
puts "Please enter host:"
hostname = STDIN.gets.chop # Read host and remove the newline
port = 80
s = TCPSocket.open(hostname, port)
s.write("HEAD / HTTP/1.0\n")
s.write("\n")
while line = s.gets # Read lines from the socket
puts line.chop # And print with platform line terminator
end
s.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment