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");
for i in 0..addrs.len() {
println(addrs[i]);
}
let first = dns.lookup_host("localhost");
println(first);
}
resolveResolve a hostname to all associated IP addresses.
Returns a vector of IP address strings. Returns an empty vector if the hostname cannot be resolved.
let addrs = dns.resolve("localhost"); // ["127.0.0.1", "::1"]
try_resolveResolve a hostname to all associated IP addresses.
Returns Err(fs.io_error_from_errno(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 the first resolved IP address as a string, or an empty string if the hostname cannot be resolved.
let ip = dns.lookup_host("localhost"); // "127.0.0.1"
try_lookup_hostResolve a hostname to its first IP address.
Returns Err(fs.io_error_from_errno(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 returns an
empty vector โ the underlying getaddrinfo keeps running on the shared
blocking pool (its result is discarded), so the calling scheduler thread
returns within deadline_ms even if the resolver is stalled.
let addrs = dns.resolve_timed("slow.example.com", 500);
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.