k.net.ping
Probe host connectivity and round-trip time with ICMP
| Execution Context | Prerequisites | Typical Use |
|---|---|---|
| KScript API, Page / View server scripts | Host network permits outbound ICMP (some cloud hosts block ICMP) | Checking hostname reachability and round-trip latency |
k.net.ping sends an ICMP Echo request to a specified hostname or IP address and returns the probe result.
Quick Start
js
k.api.get("ping", () => {
const result = k.net.ping("kooboo.com")
return {
ip: result.ip,
milliseconds: result.time,
reachable: result.success
}
})ping()
ping(command) sends an ICMP request to a host name or IP address.
| Parameter | Type | Required | Description |
|---|---|---|---|
command | string | Yes | Host name or IP address to probe |
Returns: PingResult ({ ip: string, time: number, success: boolean }).
| Field | Description |
|---|---|
ip | Resolved IP address |
time | Round-trip time in milliseconds |
success | Whether the ICMP request succeeded |
js
const result = k.net.ping("kooboo.com")
return {
ip: result.ip,
milliseconds: result.time,
reachable: result.success
}TypeScript Definitions
ts
interface KNET {
ping(command: string): PingResult;
}
interface PingResult {
ip: string;
time: number;
success: boolean;
}