Thursday, 25 May 2017

Ping Continuously Like Ping in CMD Using Node.Js

I want use node.js to ping host in local network. Here is my code :

var ping = require('ping');

var host2 = ['192.168.0.1', '192.168.1.2', '192.168.2.3'];

host2.forEach(function(host){
    ping.sys.probe(host, function(active){
        var info = active ? 'IP ' + host + ' = Active' : 'IP ' + host + ' = Non-Active';
        console.log(info);
    });
});

This code only run (ping) once. All I want is to ping continuously. Is this possible with node.js?

EDIT : When I run that code :

enter image description here



via Zhumpex

No comments:

Post a Comment