Java InetAddress Create getInetAddress(Socket socket)

Here you can find the source of getInetAddress(Socket socket)

Description

get Inet Address

License

Open Source License

Declaration

public static String getInetAddress(Socket socket) 

Method Source Code

//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;
    }
}

Related

  1. getInetAddress()
  2. getInetAddress()
  3. getInetAddress(final int[] octets, final int offset, final int length)
  4. getInetAddress(final String addressOrName)
  5. getInetAddress(long ip)
  6. getInetAddress(String dottedNotation)
  7. getInetAddress(String host)
  8. getInetAddress(String hostName)
  9. getInetAddress(String name)