Created
May 3, 2010 21:35
-
-
Save Fonsan/388615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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