DNS query: Difference between revisions
Content added Content deleted
(Added Powershell) |
(Added Kotlin) |
||
Line 593: | Line 593: | ||
IPv4 : 203.178.141.194 |
IPv4 : 203.178.141.194 |
||
IPv6 : 2001:200:dff:fff1:216:3eff:feb1:44d7 |
IPv6 : 2001:200:dff:fff1:216:3eff:feb1:44d7 |
||
</pre> |
|||
=={{header|Kotlin}}== |
|||
<lang scala>// version 1.1.3 |
|||
import java.net.InetAddress |
|||
import java.net.Inet4Address |
|||
import java.net.Inet6Address |
|||
fun showIPAddresses(host: String) { |
|||
try { |
|||
val ipas = InetAddress.getAllByName(host) |
|||
println("The IP address(es) for '$host' is/are:\n") |
|||
for (ipa in ipas) { |
|||
print(when (ipa) { |
|||
is Inet4Address -> " ipv4 : " |
|||
is Inet6Address -> " ipv6 : " |
|||
else -> " ipv? : " |
|||
}) |
|||
println(ipa.hostAddress) |
|||
} |
|||
} |
|||
catch (ex: Exception) { |
|||
println(ex.message) |
|||
} |
|||
} |
|||
fun main(args: Array<String>) { |
|||
showIPAddresses("www.kame.net") |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
The IP address(es) for 'www.kame.net' is/are: |
|||
ipv4 : 203.178.141.194 |
|||
ipv6 : 2001:200:dff:fff1:216:3eff:feb1:44d7 |
|||
</pre> |
</pre> |
||