Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/DNS-query/Kotlin/dns-query.kotlin
Normal file
27
Task/DNS-query/Kotlin/dns-query.kotlin
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// 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")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue