method dns.lookup
All IPv4 / IPv6 addresses of host (a name or a numeric address), in resolver order.
The lookup runs on the blocking pool; timeout and cancellation stop waiting for it.
Example:
use std.net { dns, IpAddr }
fn main() io, net {
match dns.lookup("no-such-host.invalid", 2s) {
List<IpAddr> _ => print("resolved")
NetError _ => print("not found")
}
}Output
not found
pub(api) static fn lookup(host: str, timeout: Duration? = none) -> List<IpAddr> | NetError netSince. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
host | str |
timeout | Duration? = none |
Returns
Errors
NetError- `Unavailable` (name not found), `Timeout`, `Cancelled`.
Effects
net
Defined in: std/net/net.oxl:762