ping-lite
A simple ping module for NodeJS apps.
Install
npm install ping-lite
Test
cd node_modules/ping-lite && mocha
Usage
var Ping = ; var ping = '8.8.8.8'; ping;
Events
error
= When the._bin
throws an errorresult
= When the._bin
completes, no response returns null
Methods
- #send(callback) accepts an optional callback that returns an error if there's an issue with theh
._bin
, anull
if there's no response or anInteger
if the host responds. - #start(callback) calls
#send
every 5 seconds until#stop
is called - #stop() stops active pings
Examples
// send one ping & handle results with callbacksvar Ping = ; var ping = '8.8.8.8'; ping;
// send pings until stopped & handle results with callbacksvar Ping = ; var ping = '8.8.8.8'; pingstart { console;}; ;
// send one ping & handle results with eventsvar Ping = ; var ping = '8.8.8.8'; ping; ping; ping; // or ping.start();