You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I trying to understand how a Pico W as a client can resolve a local hostname (of another Pico W) to an IP address using multicast DNS. It's simple for a PC or phone as this is built in to the o/s (Bonjour, Avahi, etc); I can just ping straight from the command line. It's also straightforward if there is a DNS server on the local network as we can give the client its IP address with WiFi.setDNS and then call WiFi.getHostname.
I think the only way is to use the MDNS.queryService method and iterate through the results, looking for a match with the target hostname. The gotcha is that this method doesn't appear to be able to resolve just hostnames; it only resolves service names (e.g. "http", "tcp"). This means that the target has to advertise a 'dummy' service (using MDNS.addService), although this could be called anything you like, e.g. "myapp", "tcp". We can then make a call to MDNS.queryService("myapp", "tcp") and iterate through the results.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I trying to understand how a Pico W as a client can resolve a local hostname (of another Pico W) to an IP address using multicast DNS. It's simple for a PC or phone as this is built in to the o/s (Bonjour, Avahi, etc); I can just ping straight from the command line. It's also straightforward if there is a DNS server on the local network as we can give the client its IP address with WiFi.setDNS and then call WiFi.getHostname.
I think the only way is to use the MDNS.queryService method and iterate through the results, looking for a match with the target hostname. The gotcha is that this method doesn't appear to be able to resolve just hostnames; it only resolves service names (e.g. "http", "tcp"). This means that the target has to advertise a 'dummy' service (using MDNS.addService), although this could be called anything you like, e.g. "myapp", "tcp". We can then make a call to MDNS.queryService("myapp", "tcp") and iterate through the results.
Have I missed anything ?
Beta Was this translation helpful? Give feedback.
All reactions