Code Monkey home page Code Monkey logo

mdns's Introduction

mdns

Build Status crates.io MIT license

Documentation

An multicast DNS client in Rust.

Error logging is handled with the log library.

Wikipedia

Example

Find IP addresses for all Chromecasts on the local network.

use futures_util::{pin_mut, stream::StreamExt};
use mdns::{Error, Record, RecordKind};
use std::{net::IpAddr, time::Duration};


const SERVICE_NAME: &'static str = "_googlecast._tcp.local";

#[async_std::main]
async fn main() -> Result<(), Error> {
    // Iterate through responses from each Cast device, asking for new devices every 15s
    let stream = mdns::discover::all(SERVICE_NAME, Duration::from_secs(15))?.listen();
    pin_mut!(stream);

    while let Some(Ok(response)) = stream.next().await {
        let addr = response.records()
                           .filter_map(self::to_ip_addr)
                           .next();

        if let Some(addr) = addr {
            println!("found cast device at {}", addr);
        } else {
            println!("cast device does not advertise address");
        }
    }

    Ok(())
}

fn to_ip_addr(record: &Record) -> Option<IpAddr> {
    match record.kind {
        RecordKind::A(addr) => Some(addr.into()),
        RecordKind::AAAA(addr) => Some(addr.into()),
        _ => None,
    }
}

mdns's People

Contributors

bkchr avatar dylanmckay avatar georgehahn avatar icewind1991 avatar ranfdev avatar ruuda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mdns's Issues

DNS(LabelIsNotAscii)

using the chromecast example but switching to compantion-link._tcp.local, some names panic. Not sure what the best course of action is, to support UTF-8 maybe?

How to use this as a library?

Hi,
Thanks for your work.

I'm still learning Rust, so it's likely I'm just confused. But it seems like doing anything beyond modifying the service name that gets passed to discover::all() in the given example isn't going to work -- due to what has been exposed as public and what has not been exposed. For example, can a user of this crate set the timeout? I don't see a way to do that. Since Discovery is public but composed of fields that are not public, I don't think I can ever instantiate a Discovery to set the timeout; or any other way to set the timeout without modifying the crate. Is that right?

Example without tokio::main?

I think it would be awesome if there was an example showing how to call this crate from a main that does not use tokio::main, and to get one single result back and print it! :)

(I tried to use this crate to create a simple blocking function that I could call to look up things on the local network using mdns. I failed, because the example uses tokio::main and I failed to understand how to stop the stream so it just continued giving responses.)

Endless loop floods the network

First of all, thanks for building this library! It does return what I need, but there is a slight issue.

When I run cargo run --example chromecast_discovery, the discover::all iterator keeps on producing responses endlessly.

Timestamped output
Apr 17 23:58:48 found cast device at 192.168.1.140
Apr 17 23:58:49 found cast device at 192.168.1.140
Apr 17 23:58:49 found cast device at 192.168.1.140
Apr 17 23:58:50 found cast device at 192.168.1.140
Apr 17 23:58:50 found cast device at 192.168.1.140
Apr 17 23:58:51 found cast device at 192.168.1.140
Apr 17 23:58:51 found cast device at 192.168.1.140
Apr 17 23:58:51 found cast device at 192.168.1.140
Apr 17 23:58:51 found cast device at 192.168.1.140
Apr 17 23:58:51 found cast device at 192.168.1.140
Apr 17 23:58:52 found cast device at 192.168.1.140
Apr 17 23:58:52 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:53 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:54 found cast device at 192.168.1.140
Apr 17 23:58:55 found cast device at 192.168.1.140
Apr 17 23:58:55 found cast device at 192.168.1.140
Apr 17 23:58:56 found cast device at 192.168.1.140
Apr 17 23:58:56 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:57 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:58 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:58:59 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
Apr 17 23:59:00 found cast device at 192.168.1.140
^C

While the application is running, I notice degraded performance of my network, to the point where websites barely load. This also happens on different machines from the one running the application. I suspect the application is somehow saturating the network. I have a single Chromecast Audio in my network. I am running the application on Linux 4.15.15-1-ARCH.

Running avahi-browse --terminate _googlecast._tcp does return a single result before exiting and causes no network issues.

I can reproduce this problem consistently, and I would be happy to provide more information to help debug this issue.

tokio/async-std features

Hello! I'm currently using mdns 2.0.2, as it's the last version that works with the tokio runtime, which I use in my app.

in a tokio app, mdns 3.x never streams anything, likely due to a runtime conflict. but 2.x works perfectly fine.

so i'm suggesting that both tokio and async-std be supported via features.

The stream in the example returns the same IP repeatedly and never terminates

The stream in the example keeps on returning the same IP address again and again and the while let loop never breaks, which means I cannot use any of the discovered devices as the loop is infinite.

I have copy/pasted the example and just changed the SERVICE_NAME to "_airplay._tcp.local" and it keeps printing the same Airplay devices agai and again. The example SERVICE_NAME "_googlecast._tcp.local" just hangs without output since I don't have any Chromecast devices on my network.

I tried on both Windows and Mac devices and the issue is same in both.

image

Doesn't find some of my devices

See for example this NVidia shield listed by avahi:

$ avahi-browse _nv_shield_remote._tcp --resolve
+ enp0s25 IPv6 SHIELD                                        _nv_shield_remote._tcp local
+ enp0s25 IPv4 SHIELD                                        _nv_shield_remote._tcp local
= enp0s25 IPv4 SHIELD                                        _nv_shield_remote._tcp local
   hostname = [Android.local]
   address = [192.168.1.58]
   port = [8987]
   txt = ["SERVER=aac0f0d6fbb59b5c"]
= enp0s25 IPv6 SHIELD                                        _nv_shield_remote._tcp local
   hostname = [Android.local]
   address = [192.168.1.58]
   port = [8987]
   txt = ["SERVER=aac0f0d6fbb59b5c"]

But running the chromecast_discovery example with _nv_shield_remote._tcp.local as SERVICE_NAME doesn't list those services.

For some reason, the IPv4 is also removed from avahi-browse while the example is running:
- enp0s25 IPv4 SHIELD _nv_shield_remote._tcp local

Seemingly broken on Windows

Title. Wireshark shows that the packets seem to be transmitting, but mdns doesn't receive them?

image

If I wait a while (after inserting a dbg! into mdns), it seems to detect everything but my target:

image

Here's my code:

async fn find_server() -> Result<Vec<Ipv4Addr>> {
	let stream = mdns::discover::all("_name._tcp.local", Duration::from_secs(15))?
		.ignore_empty(false)
		.listen();
	pin_mut!(stream);

	let mut servers = Vec::new();

	let _ = timeout(Duration::from_secs(20), async {
		while let Some(Ok(response)) = stream.next().await  {
			// IT DOES NOT GET TO THIS POINT, stream hangs until timeout kicks in
			let addr = response
				.records()
				.filter_map(|record| match record.kind {
					RecordKind::A(addr) => Some(addr),
					_ => None,
				})
				.next();

			if let Some(addr) = addr {
				println!("found cast device at {}");
				servers.push(addr);
				return;
			}
		}
	})
	.await;

	println!("done");

	Ok(servers)
}

The mDNS server is working - I can view it perfectly fine from a Bonjour viewer app on iOS.

Clarify README.md

It would be helpful if README.md explained which features of mDNS this crate implements. mDNS documentation

If I am not mistaken, it performs queries in an approx-periodical way and gives a collection of responses - "One-Shot Multicast DNS Queries".

It's totally ok for many use cases, but it is not full mDNS implementation. But there are also other mDNS queries (Section 5)

Publish new services

Maybe I am missing something, but how do I publish a new service? It seems that currently only the discovery is supported, right? If so, are there any plans to add the support for publishing the new services? (like the one can do with Bonjour / Avahi)

Example never returns from stream.nex().await

The only modification I made to the example code provided in the docs is the SERVICE_NAME to a known service on my network.

Running the program, it never returned any output.

I then commented out the "while loop" and added a single manual entry for the next item and a print statement right before and right after it. This second print statement is never reached.

It looks like "stream.next().await" never returns.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.