How to do an mDNS query

Sorry I am new to freeRTOS and mDNS. My system has a Realtek rtl8721. The realtek sdk does include lwip. I try to do a mdns query from it looking for a particular service in the WiFi network. But the mdns code in lwip seems to be only for a service with responder and everything. Not something I can use to do a query. I also see information about mDNS on this page: 03-Libraries/02-FreeRTOS-plus/02-FreeRTOS-plus-TCP/02-Networking-basics/21-mDNS. So do I just call FreeRTOS_gethostbyname() ? This page is updated just this month. Does it mean this is a new feature so the older version I use may not support this? Also what shall I pass to this function? Something like: _myservice._tcp.local? Can’t find such information from the API reference page: 03-Libraries/02-FreeRTOS-plus/02-FreeRTOS-plus-TCP/09-API-reference/19-gethostbyname. Sorry, the system doesn’t allow me to put links in the post.
Any information is appreciated.

Thank you.

Hi @510HM,
lwip and FreeRTOS-Plus-TCP are both TCP/IP stacks to provide network capability for the device. To invoke FreeRTOS_gethostbyname, you must integrate FreeRTOS-Plus-TCP into your application. Or you can try search if Realtek’s SDK already provides options to use FreeRTOS-Plus-TCP.

Porting Guide:

Thank you.

Thank you, Actory. I found a function in lwip: dns_gethostbyname. When LWIP_DNS_SUPPORT_MDNS_QUERIES is enabled. This function can do mdns resolution, similar to FreeRTOS_gethostname, I guess. However, it still needs the hostname, and won’t work on service name only. Eventually, I have to write my own code do do mdns query and parse the mdns response to acquire the ip address. Anyway, it works now.

1 Like

Thanks for reporting back!