How to “Ping” from a Node.js app?

You could use exec to call the system ping command

var exec = require('child_process').exec;
exec("ping -c 3 localhost", function (err, stdout, stderr) {
    console.log(stdout);
});

Leave a Comment