Skip to content

Instantly share code, notes, and snippets.

@hepplerj
Last active September 19, 2017 17:40
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 hepplerj/5a72d90e1c54698a700110f8aaeb504a to your computer and use it in GitHub Desktop.
Save hepplerj/5a72d90e1c54698a700110f8aaeb504a to your computer and use it in GitHub Desktop.
Checking server connections
var http = require('http');
function handler(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello world\n');
}
http.createServer(handler).listen(3000, '127.0.0.1');
http.createServer(handler).listen(3001, 'localhost');
http.createServer(handler).listen(3002, '127.0.0.1'); // ifconfig
http.createServer(handler).listen(3003, 'host.example.com'); // echo $HOSTNAME
http.createServer(handler).listen(3004, 'LocalHostName.local'); // scutil --get LocalHostName
// $ node multiserver.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment