Reputation: 189
I am able to poll a website using Node.js but how do I check with some local machine.Just want to check if some "xyz" machine is active on the network.
Upvotes: 0
Views: 230
Reputation: 3343
I am not sure exactly what you wanna ask though there is no difference between local servers and global servers.it's a only matter of whether you access to the server from inside of the LAN or outside of it.
if you install HTTP server on the machine you want to check, you can check its status code like usual website's servers.
and there is also modules for ping such as https://npmjs.org/package/net-ping/ all you have to do is to replace target IP address to private IP address like 192.168..
Upvotes: 1
Reputation: 5923
Ok so I guess you used http
to request an address?
If so, if you request a non active machine, you should get an error. To catch this error, simple react at the error event:
http.get("http://idontexistonthenetwork", function(res) {
console.log("Got response: " + res.statusCode);
}).on('error', function(e) {
console.log("Got error: " + e.message);
});
Documentation: http://nodejs.org/api/http.html#http_http_get_options_callback
P.S: Hope it answer your question. Don't hesitate to precise if you need something more specific like using websocket, IP discovering or else...
Upvotes: 0