Here you can find the source of getInetAddress(Socket socket)
public static String getInetAddress(Socket socket)
//package com.java2s; /*//from ww w. java 2 s . c o m * Copyright (c) Mirth Corporation. All rights reserved. * * http://www.mirthcorp.com * * The software in this package is published under the terms of the MPL license a copy of which has * been included with this distribution in the LICENSE.txt file. */ import java.net.Socket; public class Main { public static String getInetAddress(Socket socket) { String inetAddress = socket == null || socket.getInetAddress() == null ? "" : socket .getInetAddress().toString() + ":" + socket.getPort(); if (inetAddress.startsWith("/")) { inetAddress = inetAddress.substring(1); } return inetAddress; } }