pub fn request<A: ToSocketAddrs>(addr: A) -> io::Result<protocol::Packet> {
    let mut last_err = None;

    for addr in addr.to_socket_addrs()? {
        let bind_addr = match addr {
            SocketAddr::V4(_) => Ipv4Addr::UNSPECIFIED.into(),
            SocketAddr::V6(_) => Ipv6Addr::UNSPECIFIED.into(),
        };

        match request_with_bind_addr(addr, bind_addr) {
            Ok(packet) => return Ok(packet),
            Err(err) => last_err = Some(err),
        }
    }

    match last_err {
        Some(err) => Err(err),
        None => Err(io::Error::new(io::ErrorKind::NotFound, format!("Address resolved to empty")))
    }
}
/// Send a blocking request to an ntp server with a hardcoded 5 second timeout.
///
///   `addr` can be any valid socket address
///
/// Returns an error if the server cannot be reached or the response is invalid.
///
/// If `addr` resolves to multiple IP addresses, they are tried in order until
/// a request succeeds.
/// If all requests fail, the last error is returned.
Send a blocking request to an ntp server with a hardcoded 5 second timeout.
`addr` can be any valid socket address

Returns an error if the server cannot be reached or the response is invalid.

If `addr` resolves to multiple IP addresses, they are tried in order until
a request succeeds.
If all requests fail, the last error is returned.
Send a blocking request to an ntp server with a hardcoded 5 second timeout . ` addr ` can be any valid socket address Returns an error if the server cannot be reached or the response is invalid . If ` addr ` resolves to multiple IP addresses they are tried in order until a request succeeds . If all requests fail the last error is returned .
pub fn request<A: ToSocketAddrs>(addr: A) -> io::Result<protocol::Packet> {
    let mut last_err = None;
    for addr in addr.to_socket_addrs()? {
        let bind_addr = match addr {
            SocketAddr::V4(_) => Ipv4Addr::UNSPECIFIED.into(),
            SocketAddr::V6(_) => Ipv6Addr::UNSPECIFIED.into(),
        };
        match request_with_bind_addr(addr, bind_addr) {
            Ok(packet) => return Ok(packet),
            Err(err) => last_err = Some(err),
        }
    }
    match last_err {
        Some(err) => Err(err),
        None => Err(io::Error::new(io::ErrorKind::NotFound, format!("Address resolved to empty")))
    }
}
pub fn request < A : ToSocketAddrs > ( addr : A ) -> io :: Result < protocol :: Packet > { let mut last_err = None ; for addr in addr . to_socket_addrs ( ) ? { let bind_addr = match addr { SocketAddr :: V4 ( _ ) => Ipv4Addr :: UNSPECIFIED . into ( ) , SocketAddr :: V6 ( _ ) => Ipv6Addr :: UNSPECIFIED . into ( ) , } ; match request_with_bind_addr ( addr , bind_addr ) { Ok ( packet ) => return Ok ( packet ) , Err ( err ) => last_err = Some ( err ) , } } match last_err { Some ( err ) => Err ( err ) , None => Err ( io :: Error :: new ( io :: ErrorKind :: NotFound , format ! ( " " ) ) ) } }
Send a blocking request to an ntp server with a hardcoded 5 second timeout.
Send a blocking request to an ntp server with a hardcoded 5 second timeout .
addr
A
addr
A