resolve
resolve resolves a host name or address into textual addresses.
Resolution runs asynchronously and accepts an optional timeout in milliseconds. Network failures fulfill the promise with Err(NetError).
Signature
resolve(host: string, timeoutMs?: u64): Promise<Result<string[], NetError>>tyrus
import { NetError, resolve } from "tyrus:net";
async function lookup(): Promise<void> {
const result: Result<string[], NetError> = await resolve("localhost", 1000);
match (result) {
Ok(addresses) => { print(addresses.length); } // 1
Err(error) => { printError(error.code); } // ERR_NET_RESOLVE
}
}Error Handling
error
tyrus
import { NetError, resolve } from "tyrus:net";
async function lookup(): Promise<void> {
const result: Result<string[], NetError> = await resolve("invalid.invalid", 1000);
match (result) {
Ok(_) => {}
Err(error) => { printError(error.code); } // ERR_NET_RESOLVE
}
}Typical failures include ERR_NET_RESOLVE and ERR_NET_TIMEOUT.
