This is the documentation for the development version. There are no official binaries for it; build it from the source code in git. Download links on these pages work only after the release. For the current release, see version 7.0.

Net::ResolveHostname

Net::ResolveHostname(hostname, addressFamily): String

Resolve hostname to IP address

Table 1. Parameters

hostname

String

Hostname

addressFamily

Integer

Optional. 6 to resolve to an IPv6 address; any other value or omitted resolves to IPv4.

Return

IP address of the requested family as a String, or null if the name cannot be resolved. If hostname is already an IP address, that address is returned in normalized form (for example, 2001:0DB8:0:0:0:0:0:1 as 2001:db8::1), whatever family is requested.

println(Net::ResolveHostname("localhost")); //Will print "127.0.0.1"
println(Net::ResolveHostname("localhost", 6)); //Will print "::1"