Search code examples
node.js

How to "Ping" from a Node.js app?


I want to ping a server from my node.js app.

Is that doable?

Thanks


Solution

  • 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);
    });