Here you can find the source of getHostName(SocketAddress socketAddress)
public static String getHostName(SocketAddress socketAddress)
//package com.java2s; //License from project: Apache License import java.net.*; public class Main { public static String getHostName(SocketAddress socketAddress) { if (socketAddress == null) { return null; }/*from w w w.j a va 2s. c o m*/ if (socketAddress instanceof InetSocketAddress) { InetAddress addr = ((InetSocketAddress) socketAddress).getAddress(); if (addr != null) { return addr.getHostAddress(); } } return null; } }