Here you can find the source of getSocketAddress(InetSocketAddress socket)
public static String getSocketAddress(InetSocketAddress socket)
//package com.java2s; //License from project: Apache License import java.net.InetSocketAddress; public class Main { public static String getSocketAddress(InetSocketAddress socket) { return getHostName(socket) + ":" + getPort(socket); }//from w w w.j a v a2 s .com public static String getHostName(InetSocketAddress socket) { return socket.getHostName(); } public static String getPort(InetSocketAddress socket) { return socket.getPort() + ""; } }