mjansson / mdns

Public domain mDNS/DNS-SD library in C
The Unlicense
459 stars 120 forks source link

Not sure how to use #3

Closed johanneskares closed 5 years ago

johanneskares commented 5 years ago

Hey there,

thanks for your library. Since documentation is very limited maybe you can give me a hint of how to get going. I compile an run your c file this is the output I get:

Opened IPv4 socket for mDNS/DNS-SD
Sending DNS-SD discovery
Reading DNS-SD replies
192.168.0.30:5353 : answer PTR _rfb._tcp.local. type 12 rclass 0x1 ttl 10 length 12
192.168.0.30:5353 : answer PTR _smb._tcp.local. type 12 rclass 0x1 ttl 10 length 7
192.168.0.30:5353 : answer PTR _companion-link._tcp.local. type 12 rclass 0x1 ttl 10 length 18
Sending mDNS query
Reading mDNS replies
Closed socket
Program ended with exit code: 0

I was expecting that if I run the same command line app in the network I will get more replies in either Reading DNS-SD replies or Reading mDNS replies, but whatever I do I can't ever get a different result than what is seen above. I'm working on MacOS.

Johannes

mjansson commented 5 years ago

The supplied .c file is just an example app. To use the library for DNS-SD discovery you do what the app does, call mdns_discovery_send on a socket and then read replies with mdns_discovery_recv and your own callback to filter out the services you are interested in.

Then you can call mdns_query_send to get details for a specific record. The example app queries ssh service, if you have none running on your local network there will be no replies.

I'll try to get time to write some docs into the header