Here you can find the source of getIpAsString(SocketAddress address)
public static String getIpAsString(SocketAddress address)
//package com.java2s; //License from project: Apache License import java.net.InetSocketAddress; import java.net.SocketAddress; public class Main { public static String getIpAsString(SocketAddress address) { try {//from www. j ava2 s .com if (address instanceof InetSocketAddress) { return ((InetSocketAddress) address).getAddress().getHostAddress(); } return address.toString().split("/")[1].split(":")[0]; } catch (Throwable e) { e.printStackTrace(); } return "0.0.0.0"; } }