Skip to content

Instantly share code, notes, and snippets.

@sj82516
Created April 7, 2019 09:31
Show Gist options
  • Select an option

  • Save sj82516/f19e83a2f44c8cff368c6a5cf61bb3db to your computer and use it in GitHub Desktop.

Select an option

Save sj82516/f19e83a2f44c8cff368c6a5cf61bb3db to your computer and use it in GitHub Desktop.
var net = require('net');
var opts = {
host: 'localhost',
port: 3000
}
var socket = net.connect(opts, function () {
socket.end('GET / HTTP/1.0\r\n' +
'Host: localhost\r\n' +
'\r\n', (err) => {
console.log("first http done");
socket.destroy();
var secondSocket = net.connect(opts, function () {
secondSocket.end('GET / HTTP/1.0\r\n' +
'Host: localhost\r\n' +
'\r\n', (err)=>{
console.log("second http done");
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment