The following functions can be used to convert between host names and IP addresses. Both functions return all information returned by the resolver in a table of the form:
resolved = {
name = canonic-name,
alias = alias-list,
ip = ip-address-list
}
Note that the alias list can be empty.
socket.dns.tohostname()
Converts from IP address to host name.
Address can be an IP address or host name.
The function a string with the canonic host name of the given address, followed by a table with all information returned by the resolver. In case of error, the function returns nil followed by an error message.
socket.dns.toip()
Converts from host name to IP address.
Address can be an IP address or host name.
Returns a string with the first IP address found for address, followed by a table with all information returned by the resolver. In case of error, the function returns nil followed by an error message.