Skip to content

Instantly share code, notes, and snippets.

@arbo77
Created November 12, 2014 19:20
Show Gist options
  • Save arbo77/832e8450858174fad9aa to your computer and use it in GitHub Desktop.
Save arbo77/832e8450858174fad9aa to your computer and use it in GitHub Desktop.
NodeJS check local port
var args = process.argv.slice(2);
if(args.length == 0){
console.log('port required')
process.exit(0)
}
var port = parseInt(args[0]);
var net = require('net');
var client = net.connect({port: port},
function() {
console.log('server alive');
client.end();
})
.on('error',function(){
console.log('server down');
})
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment