Internet Control Message Protocol in Node
Internet Control Message Protocol implementation in Node (it has Promises).
How to install
Install with npm:
npm install --save icmp
How to use
You can view examples in
Little example for lazy peoples who don't want to open
Here's how to find if a network card is receiving or not (basic ping) -->
const icmp = ;icmp;
The requested HOST (can be an IP)
The requested IP, when host parameter is given to the constructor, the DNS will be resolved to get this IP adress
This property will be
false, depending on the ping response
ICMP response type, will be one from this array:
'REPLY' 'NA' 'NA' 'DESTINATION_UNREACHABLE' 'SOURCE_QUENCH' 'REDIRECT'
ICMP response code, will be one from this array:
'NET' 'HOST' 'PROTOCOL' 'PORT' 'FRAGMENTATION' 'ROUTE_FAILED' 'NET_UNKNOWN' 'HOST_UNKNOWN' 'HOST_ISOLATED' 'NET_PROHIBITED' 'HOST_PROHIBITED' 'NET_UNREACHABLE' 'HOST_UNREACHABLE' 'COMM_PROHIBITED' 'HOST_PRECEDENCE' 'PRECEDENCE_CUTOFF' 'NETWORK' 'HOST' 'SERVICE_NETWORK' 'HOST_NETWORK'
timeout of each methods is
(static) ICMP.ping(host: string, timeout?: number): Promise
Send a ping to a specific host. Returns a Promise resolving an ICMP instance and rejecting an Error.
ICMP.ping(timeout?: number): Promise
Send a ping to the defined ICMP instance's host. Returns a Promise, resolving nothing and rejecting an Error.
(static) ICMP.send(host: string, data?: string)
Send data to a specific host through ICMP. Returns a Promise resolving an ICMP instance and rejecting an Error.
ICMP.send(data?: string, timeout?: number)
Send data to the defined ICMP instance's host. Returns a Promise resolving nothing and rejecting an Error.
Close the raw socket stream. Can be used to stop a request.