Skip to content

Instantly share code, notes, and snippets.

Created March 14, 2013 22:05
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 anonymous/5dd315095a9f06dc98a3 to your computer and use it in GitHub Desktop.
Save anonymous/5dd315095a9f06dc98a3 to your computer and use it in GitHub Desktop.
var Socket = require('net').Socket;
var http = require('http');
http.createServer(function(req, res) {
console.log('request')
res.end();
}).listen(3000);
var go = true;
while(go) {
if (!go) break;
var s = new Socket();
s.once('connect', function() {
this.write('GET / HTTP/1.1\r\n\r\n');
connect();
});
s.once('error', function(err) {
go = false;
console.log('error')
});
s.once('close', function() {
console.log('close');
})
s.connect(3000, '127.0.0.1');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment