The DNS client/resolver service allows user application to resolve IP addresses of internet hosts that are identified by a host name.
It does this by sending DNS request to a DNS Server. The IP address of a DNS Server is specified manually or can be obtained from the DHCP Server for the Local Area Network.
After the DNS client is initialized by calling the fnet_dns_init() function, the user application should call the main service-polling function fnet_service_poll() periodically in background.
The resolved IP-address will be passed to the fnet_dns_callback_resolved_t callback function, which is set during the DNS-client service initialization.
The DNS client service is released automatically as soon as the requested host name is fully resolved or an error occurs. Your application code may continue to call fnet_service_poll() to handle other services, but this will not have any impact on the DNS client communication until you initialize the next IP address resolving by calling fnet_dns_init() again.
For the DNS-client service example, refer to the FNET Shell demo source code.
- Note
- Current version of the DNS client:
- does not cache the resolved IP addresses.
- can process only one request at a time.
- uses UDP protocol, without message truncation.
- does not support DNS servers without recursion (all real-life DNS servers support it).
- takes the first resolved IP address, even if the DNS server provides several ones.
Configuration parameters: