The get_host_by_name function resolves the IP address of a host from a hostname. The argument hostn is a pointer to a NULL terminated string that specifies the hostname. The function get_host_by_name starts the DNS client on TCPnet, to send a request to the DNS server. The argument cbfunc specifies a user provided callback function that the DNS client calls when an event ends the DNS session. The DNS client specifies the event and the host IP address (in case of DNS_EVT_SUCCESS) when calling the cbfunc function. | Event | Description |
|---|
| DNS_EVT_SUCCESS | The IP address has been resolved. The argument host_ip of the function cbfunc points to a 4-byte buffer containing the IP address in dotted decimal notation. | | DNS_EVT_NONAME | The hostname was not found in the DNS server. | | DNS_EVT_TIMEOUT | The timeout has expired before the IP address could be resolved. | | DNS_EVT_ERROR | A DNS communication protocol error has occurred. This can also result from misplaced dots in the hostname or incorrect name labels. |
The get_host_by_name function is in the RL-TCPnet library. The prototype is defined in rtl.h. note - The hostname argument hostn can also point to the dotted decimal IP address in sting format (for example "192.168.0.100"). In this case, the DNS client calls the cbfunc function immediately with the IP address.
|