std::net::dnsDNS hostname resolution.
Resolve hostnames to IP address strings using the system resolver.
import std.net.dns;
fn main() {
let addrs = dns.resolve("localhost") handle error {
println(f"operation failed: {error}");
return;
};
for addr in addrs {
println(addr);
}
let first = dns.lookup_host("localhost") handle error {
println(f"operation failed: {error}");
return;
};
println(first);
}
resolveResolve a hostname to all associated IP addresses.
Returns Err(NetError.Other(0)) when the hostname cannot be resolved.
Use this when structured error handling with ? is preferred over an
empty-vector sentinel.
Note: DNS has no OS errno channel; the errno payload is always 0. A follow-up issue will wire errno once hew_dns_resolve exposes it.
lookup_hostResolve a hostname to its first IP address.
Returns Err(NetError.Other(0)) when the hostname cannot be resolved.
Use this when structured error handling with ? is preferred over an
empty-string sentinel.
Note: DNS has no OS errno channel; the errno payload is always 0. A follow-up issue will wire errno once hew_dns_lookup_host exposes it.
resolve_timedResolve a hostname to all associated IP addresses with a deadline.
deadline_ms <= 0 disables the deadline. On deadline expiry or resolution
failure returns an empty vector. The resolver keeps running after the
deadline; its late answer is discarded.
import std.net.dns;
fn main() {
let addrs = dns.resolve_timed("slow.example.com", 500);
for addr in addrs {
println(addr);
}
}
lookup_host_timedResolve a hostname to its first IP address with a deadline.
deadline_ms <= 0 disables the deadline. On deadline expiry or resolution
failure returns an empty string.