Here you can find the source of getHostPort(Socket s)
public static String getHostPort(Socket s)
//package com.java2s; //License from project: Open Source License import java.net.Socket; public class Main { public static String getHostPort(Socket s) { String h = s.getInetAddress().getHostAddress().toString(); int port = s.getPort(); return h + ":" + port; }//from ww w.j a v a 2s . co m }