async fn query_loop(sock: Arc<UdpSocket>, interval: Duration) {
    let to_addr: SocketAddr = match sock.local_addr() {
        Ok(SocketAddr::V4(_)) => (MDNS_MCAST_V4, MDNS_PORT).into(),
        Ok(SocketAddr::V6(_)) => (MDNS_MCAST_V6, MDNS_PORT).into(),
        Err(err) => {
            log::info!("resolving local socket addr failed with: {}", err);
            return;
        }
    };

    loop {
        if let Err(err) = sock.send_to(&QUERY_BUF, to_addr).await {
            log::info!(
                "mdns query failed from {}: {}",
                sock.local_addr().map(|a| a.to_string()).unwrap_or("unknown".to_string()),
                err
            );
            return;
        }

        Timer::new(interval).await;
    }
}
// query_loop broadcasts an mdns query on sock every interval.
query_loop broadcasts an mdns query on sock every interval.
query_loop broadcasts an mdns query on sock every interval .
async fn query_loop(sock: Arc<UdpSocket>, interval: Duration) {
    let to_addr: SocketAddr = match sock.local_addr() {
        Ok(SocketAddr::V4(_)) => (MDNS_MCAST_V4, MDNS_PORT).into(),
        Ok(SocketAddr::V6(_)) => (MDNS_MCAST_V6, MDNS_PORT).into(),
        Err(err) => {
            log::info!("resolving local socket addr failed with: {}", err);
            return;
        }
    };
    loop {
        if let Err(err) = sock.send_to(&QUERY_BUF, to_addr).await {
            log::info!(
                "mdns query failed from {}: {}",
                sock.local_addr().map(|a| a.to_string()).unwrap_or("unknown".to_string()),
                err
            );
            return;
        }
        Timer::new(interval).await;
    }
}
async fn query_loop ( sock : Arc < UdpSocket > , interval : Duration ) { let to_addr : SocketAddr = match sock . local_addr ( ) { Ok ( SocketAddr :: V4 ( _ ) ) => ( MDNS_MCAST_V4 , MDNS_PORT ) . into ( ) , Ok ( SocketAddr :: V6 ( _ ) ) => ( MDNS_MCAST_V6 , MDNS_PORT ) . into ( ) , Err ( err ) => { log :: info ! ( " " err ) ; return ; } } ; loop { if let Err ( err ) = sock . send_to ( & QUERY_BUF , to_addr ) . await { log :: info ! ( " " sock local_addr ( ) map ( a a to_string ( ) ) unwrap_or ( " " to_string ( ) ) err ) ; return ; } Timer :: new ( interval ) . await ; } }
query_loop broadcasts an mdns query on sock every interval.
query_loop broadcasts an mdns query on sock every interval .
sock
Arc<UdpSocket>
interval
Duration
sock
Arc<UdpSocket>
interval
Duration