Function netdb::hosts::get_host_by_name [] [src]

pub fn get_host_by_name(name: &str) -> Result<Option<HostEnt>, Error>

Returns host information for a given host name.

The name is either a hostname, an IPv4 or IPv6 address in its standard text notation. In the latter two cases, no lookups are performed and a HostEnt is returned with name as the canonical name, the parsed address as the sole address, and no aliases.

Otherwise the name is interpreted as a host name and lookups according to the system configuraition are performed.

The function waits for all necessary IO to resolve. Upon success, it returns a HostEnt value if a host for the given name was found or Ok(None) otherwise.

Limitations

For this initial version of the crate, the lookup is a files lookup first and only if that does fail to yield a result, a DNS query for both A and AAAA records. This initial version also does not yet fill the aliases list of the returned HostEnt.