Skip to content

ping

Gate: gated on net, target the hostname or IP being pinged · read

One ICMP echo, one answer. Gated on the net kind like everything else that leaves the machine: a ping sweep is a perfectly good way to map a network you were never meant to see, so reachability is a decision, not a freebie.

Input

FieldTypeRequiredNotes
hoststringyesThe hostname or IP to ping.

Output

A JSON object — reachability and round-trip time:

{ "host": "example.com", "ip": "93.184.216.34", "ok": true, "rtt_ms": 12 }

ok is always true in a result — a host that does not answer within the timeout produces an error, not a result saying so. Which is a distinction worth keeping: no answer means no answer, and never that the host does not exist.

From JavaScript

const r = nocturn.ping("example.com");
console.log(r.rtt_ms + " ms"); // a host that did not answer would have thrown

Notes

Unprivileged ICMP is an OS permission. Where the platform refuses it the call fails after the approval, as an error from the socket — not as a denial from the gate.