티스토리 뷰

공부

[kotlin] ip

승가비 2023. 2. 14. 17:11
728x90
fun ip(): String {
    val socket = Socket()

    socket.connect(InetSocketAddress("google.com", 80))
    val ip = socket.localAddress.hostAddress
    socket.close()

    return ip
}

https://stackoverflow.com/questions/9481865/getting-the-ip-address-of-the-current-machine-using-java

 

Getting the IP address of the current machine using Java

I am trying to develop a system where there are different nodes that are run on different system or on different ports on the same system. Now all the nodes create a Socket with a target IP as th...

stackoverflow.com

 

728x90
댓글