Giter Site home page Giter Site logo

Comments (15)

a13u avatar a13u commented on June 15, 2024

I tried a further test: I added my phone to the network where I can discover the printer but not the published service...
I also tried to turn off my firewalls as well my anti-virus app without any success...

from net-mdns.

richardschneider avatar richardschneider commented on June 15, 2024

@a13u Sorry that things are not working out. Can you tell me what OS your are using?

from net-mdns.

a13u avatar a13u commented on June 15, 2024

no problem ;)
I just want to find out what is happening....
I am using Windows 10

from net-mdns.

a13u avatar a13u commented on June 15, 2024

In my Windows Printers and Device-Manager I can see the printer - I guess it discovers it with noconfnetwork

from net-mdns.

richardschneider avatar richardschneider commented on June 15, 2024

I've tidied up your code, so that console output is readable. Also, see the spike that I wrote to test things out.

        public static void Main(string[] args)
        {
            var service = new ServiceProfile("x", "_sdtest-2._tcp", 1024);
            var mdns = new MulticastService();
            var sd = new ServiceDiscovery(mdns);

            mdns.NetworkInterfaceDiscovered += (s, e) =>
            {
                foreach (var nic in e.NetworkInterfaces)
                {
                    Console.WriteLine($"discovered NIC '{nic.Name}'");
                }
                sd.QueryAllServices();
            };

            sd.ServiceDiscovered += (s, serviceName) =>
            {
                Console.WriteLine("found " + serviceName);
            };
            try
            {
                sd.Advertise(service);
                mdns.Start();
                Console.ReadKey();
            }
            finally
            {
                sd.Dispose();
                mdns.Stop();
            }
        }

from net-mdns.

richardschneider avatar richardschneider commented on June 15, 2024

Can you show me the output from the above code or from running the spike.

from net-mdns.

a13u avatar a13u commented on June 15, 2024

I get nothing....
The spike project returns the following

Multicast DNS spike
IP address fe80::a4bf:df55:XXXXX
IP address 10.0.0.9
21.07.2018 16:45:25 [DEBUG] Makaretu.Dns.MulticastService - Found nic 'WLAN'.
discovered NIC 'WLAN'
got a query for _homekit._tcp.local PTR, _sleep-proxy._udp.local PTR
21.07.2018 16:46:09 [DEBUG] Makaretu.Dns.ServiceDiscovery - got query for _homekit._tcp.local PTR
got a query for _homekit._tcp.local PTR, _sleep-proxy._udp.local PTR
21.07.2018 16:46:10 [DEBUG] Makaretu.Dns.ServiceDiscovery - got query for _homekit._tcp.local PTR
got a query for _homekit._tcp.local PTR, _sleep-proxy._udp.local PTR
21.07.2018 16:46:13 [DEBUG] Makaretu.Dns.ServiceDiscovery - got query for _homekit._tcp.local PTR
got a query for _homekit._tcp.local PTR, _sleep-proxy._udp.local PTR
21.07.2018 16:46:22 [DEBUG] Makaretu.Dns.ServiceDiscovery - got query for _homekit._tcp.local PTR
got a query for _http._tcp.local PTR
21.07.2018 16:46:23 [DEBUG] Makaretu.Dns.ServiceDiscovery - got query for _http._tcp.local PTR
got a query for _http._tcp.local PTR
21.07.2018 16:46:24 [DEBUG] Makaretu.Dns.ServiceDiscovery - got query for _http._tcp.local PTR
got a query for _http._tcp.local PTR
21.07.2018 16:46:27 [DEBUG] Makaretu.Dns.ServiceDiscovery - got query for _http._tcp.local PTR

from net-mdns.

richardschneider avatar richardschneider commented on June 15, 2024

Please note that the above is only discovering services available on the local network NOT the devices.

Make this change to ask for all devices (service instances) of a service

sd.ServiceDiscovered += (s, serviceName) =>
 {
       Console.WriteLine("found " + serviceName);
      mdns.SendQuery(serviceName, type: DnsType.PTR);
 };

from net-mdns.

richardschneider avatar richardschneider commented on June 15, 2024

I have not yet written a generic ServiceInstanceDiscovery (device discovery) method yet. The above code will ask for all devices with the services names and you can see the answer in the debug logs.

However to process the information you need to drop down to mdns.AnswerReceived

from net-mdns.

richardschneider avatar richardschneider commented on June 15, 2024

I'll add some device discovery into the spike. However its 03:00 my time and I'm goinf to bed. Talk to later and BTW thanks for the interest in the project.

from net-mdns.

a13u avatar a13u commented on June 15, 2024

I added sd.QueryAllServices(); to "mdns.NetworkInterfaceDiscovered += (s, e) =>.." in Spike
Now I find at least my local services ;)

from net-mdns.

a13u avatar a13u commented on June 15, 2024

Thank you for your support

from net-mdns.

a13u avatar a13u commented on June 15, 2024

I found out that my discovery app on my mobile phone was just looking for services on port 80....
Further, I guess that my printer is not working correctly...
For me, it seems like that "QueryAllServices()" has to be called continously in order to avoid missing a new service?

I am not sure, if this is the intended space for discussions - please, correct me if not:
After a service is discovered, the following code is called:

            sd.ServiceDiscovered += (s, serviceName) =>
            {
                Console.WriteLine("found " + serviceName);
                mdns.SendQuery(serviceName, type: DnsType.PTR);
            };

How can I find the host of this service? s is of type Makaretu.Dns.ServiceDiscovery --> I do not no know how to get a [DNS-Name/IP]->Service-Name Mapping

If I ping my Host-name I do not get a repsons --> I only see that a request is received - has this to be implemented by the user of the library?

Thank you for your awesome implementation and effort!

from net-mdns.

richardschneider avatar richardschneider commented on June 15, 2024

QueryAllServices does not need to be called continuously because new services will advertise themselves.

To get the service instance host name. You need to send a query for its SRV record then query for A/AAAA records.

from net-mdns.

richardschneider avatar richardschneider commented on June 15, 2024

An example browser is now at https://github.com/richardschneider/net-mdns/blob/master/Browser/Program.cs

Hope it helps.

from net-mdns.

Related Issues (20)

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.