W3cubDocs

/Rust

Function std::net::lookup_host

pub fn lookup_host(host: &str) -> Result<LookupHost>
🔬 This is a nightly-only experimental API. (lookup_host #27705)unsure about the returned iterator and returning socket addresses

Resolve the host specified by host as a number of SocketAddr instances.

This method may perform a DNS query to resolve host and may also inspect system configuration to resolve the specified hostname.

The returned iterator will skip over any unknown addresses returned by the operating system.

Examples

#![feature(lookup_host)]

use std::net;

for host in net::lookup_host("rust-lang.org")? {
    println!("found address: {}", host);
}

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/net/fn.lookup_host.html