Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get the device IP address #101

Open
kingeaglewang opened this issue Dec 9, 2020 · 0 comments
Open

Cannot get the device IP address #101

kingeaglewang opened this issue Dec 9, 2020 · 0 comments

Comments

@kingeaglewang
Copy link

In your example code,

        mdns.AnswerReceived += (s, e) =>
        {
               // Is this an answer to a service instance details?
               var servers = e.Message.Answers.OfType<SRVRecord>();
               foreach (var server in servers)
               {
                  Console.WriteLine($"host '{server.Target}' for '{server.Name}'");

                  // Ask for the host IP addresses.
                  mdns.SendQuery(server.Target, type: DnsType.A);
                  mdns.SendQuery(server.Target, type: DnsType.AAAA);
               }

            // Is this an answer to host addresses?
            var addresses = e.Message.Answers.OfType<AddressRecord>();
            foreach (var address in addresses)
            {
                Console.WriteLine($"host '{address.Name}' at {address.Address}");
            }

        };

I cannot get the address most of time, I can only get the server.Name.
I need to call sd.QueryServiceInstances(mServiceType); many times, I finally can get address.

Is any thing I need to do?
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant