networkInterfaces
networkInterfaces returns one NetworkInterface per local IP address found on every active network adapter, an adapter with both an IPv4 and an IPv6 address contributes two entries. Enumeration failures return Err(OsError) with code ERR_OS_NETWORK_INTERFACES_FAILED.
Signature
networkInterfaces(): Result<NetworkInterface[], OsError>tyrus
import { NetworkInterface, OsError, networkInterfaces } from "tyrus:os";
const result: Result<NetworkInterface[], OsError> = networkInterfaces();
match (result) {
Ok(interfaces) => { print(`${interfaces.length} address(es)`); }
Err(error) => { printError(error.code); }
}NetworkInterface Fields
| Field | Type | Meaning |
|---|---|---|
name | string | The adapter's name (e.g. "eth0", "en0", "Wi-Fi"). |
address | string | The local IP address. |
netmask | string | The subnet mask for address. |
family | string | Either "IPv4" or "IPv6". |
