LuaSocket
Network support for the Lua language

home · download · introduction · reference


DNS

Name resolution function 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.gethostname()

Returns the standard host name for the machine.

The function returns a string with the host name.

socket.dns.tohostname(address)

Converts from IP address to host name.

Address can be an IP address or host name.

The function returns 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(address)

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.