Created
November 12, 2014 19:20
-
-
Save arbo77/832e8450858174fad9aa to your computer and use it in GitHub Desktop.
NodeJS check local port
This file contains hidden or 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
| 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