Skip to content

Instantly share code, notes, and snippets.

@mgax
Created January 19, 2012 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mgax/1642679 to your computer and use it in GitHub Desktop.
Save mgax/1642679 to your computer and use it in GitHub Desktop.
Toy http server in ruby
require 'socket'
httpd = TCPServer.open('0.0.0.0', 6000)
loop {
client = httpd.accept
while line = client.gets
puts line
if line.chomp.length == 0
client.puts "200 OK\n\nhello client!\n"
break
end
end
client.close
puts '-----------------------'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment