Description
Discussion copied out from Roadmap thread here
#4821 (comment)
Things might have moved on since issue #2875
What I said:
I'd really like mDNS support in the socket.getaddrinfo() for looking up ".local" domains. (This is just the "easy" half of mDNS spec.)
Otherwise I've got to hard-code the ip-number when using mqtt to a local broker, which is not very robust as this number can change, which then requires taking down and reprogramming all my Micropython devices.
I've been getting around it using this minimal UDP sending code, which just about works on an ESP32. If this were done properly it would seriously help out with connecting embedded devices onto local networks in the real world where people don't always have access to the router to force it to use fixed ip-numbers.
What @dpgeorge said:
Note that in the stm32 port mDNS queries and the responder are enabled for boards that have network interfaces.
For esp32 I think it's just a matter of enabling the feature.
My follow up comments:
It would be perfect if gethostbyname() just worked for ".local" domains -- like it does in CPython -- so it's not a special case and people don't have to know what's going on.
It's not obvious to the programmer whether this is a Micropython issue or a platform issue. It would therefore really help out if we got an "mDNS not implemented in this platform" error for platforms where the feature is not enabled rather than just an empty list.
Chasing down this rabbit hole ends up at call to gethostbyname() in CPython, and ends at a call to dns_gethostbyname() in Micropython.
There's an mDNS implementation in arduino-esp32 land, and a lot of mDNS stuff in the esp-idf (which I believe Micropython/ESP32 is built on).
I don't know why it's not hooked up automatically, like it is in CPython.