supportsIcmp
supportsIcmp reports whether the current environment permits the sockets required by ping and traceroute.
On Linux, the result checks both socket capabilities. On macOS, it checks whether a raw ICMP socket can be opened. On Windows, it checks whether the native IP Helper ICMP handle can be opened. On unsupported platforms or restricted sandboxes it returns false.
Signature
supportsIcmp(): booleantyrus
import { supportsIcmp } from "tyrus:net";
if (supportsIcmp()) {
print("network probes available"); // "network probes available"
}Error Handling
error
tyrus
import { ping, supportsIcmp } from "tyrus:net";
async function probe(): Promise<void> {
if (!supportsIcmp()) {
print("ERR_NET_UNSUPPORTED"); // "ERR_NET_UNSUPPORTED"
return;
}
await ping("127.0.0.1");
}The capability check itself does not throw. ping and traceroute fulfill with Err(NetError) using ERR_NET_UNSUPPORTED when it returns false.
