alex-spataru / qMDNS

Implementation of a simple mDNS responder with Qt
MIT License
24 stars 7 forks source link

qMDNS for service search on Windows? #1

Open knro opened 7 years ago

knro commented 7 years ago

Thanks for developing qMDNS. I wanted a very lightweight method to search for specific Avahi services on the network. All I know is the service name. Under Linux, qMDMS seems to work fine and I get back information on the required service, but only windows all the entries returned in readResponse(...) are local services running on the PC.

There is no firewall issues as I was able to use an Avahi browser with the same network permissions and it was able to discover services over the LAN. Any pointers appreciated!

alex-spataru commented 7 years ago

Hi! IMO, there can be three causes for your issue:

  1. For some reason, Qt does not configure the sockets correctly (happened on Linux until I added some platform-specific code).
  2. qMDNS fails to read the received mDNS packets.
  3. One of your mDNS services does not setup the socket options correctly, which could block qMDNS from sending or receiving data to/from the LAN.

To verify if there's a problem with the sockets configured by Qt, you can try to check the return value of the BIND() function, which is (only) used here.

To verify if qMDNS has trouble reading mDNS packets from your LAN, check if qMDNS can decode the IP address for each host name that it finds on the LAN in the readResponse() function.

knro commented 7 years ago

Thanks for the reply! I checked the the BIND() returns success just fine. I can find my Avahi service using the Bonjour browser. Perhaps I am mis-understanding this, can I use qMDNS to lookup services by "name"?

Attached is the logs and you'll see I am trying to discover "stellarmate". On Linux, this works fine, but on Windows, I cannot get any services that do not reside on the PC. But when I use Bonjour Browser, I can see my service there just fine. The file below shows the raw response on the socket.

mdns_log.txt

alex-spataru commented 7 years ago

Yes, qMDNS was designed for the application to input a service name/host (e.g. "stellarmate.local") and discover the IP addresses of the remote host(s).

I have looked at your log file, and from what I understood (correct me if I'm wrong):

While I'm not very familiar with your issue (or DNS in general, this was a side-project for a larger program that I was developing), could you try to use Wireshark to see all the data sent/received through the mDNS services?

Wireshark can also help us to get more specific information about the remote hosts and know if your computer ever received a response from stellarmate.local since qMDNS made the query.