Created
March 20, 2011 16:51
-
-
Save PatrickLef/878447 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
## | |
## SERVER (config.ru) | |
## Start with: thin start -V -R config.ru | |
app = proc do |env| | |
[ | |
200, | |
{ | |
'Content-Type' => 'text/html', | |
'Content-Length' => '2' | |
}, | |
['hi'] | |
] | |
end | |
run app | |
## | |
## CLIENT | |
## | |
require 'socket' | |
socket = TCPSocket.new('0.0.0.0', 3000) | |
socket.write "GET /first HTTP/1.1\r\nConnection: keep-alive\r\n\r\n" | |
socket.flush | |
socket.write "GET /second HTTP/1.1\r\nConnection: close\r\n\r\n" | |
socket.flush | |
response = socket.read | |
socket.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment