Java Socket Address Get extractClientAddress(SocketAddress remoteAddress)

Here you can find the source of extractClientAddress(SocketAddress remoteAddress)

Description

extract Client Address

License

Apache License

Declaration

public static String extractClientAddress(SocketAddress remoteAddress) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.net.InetSocketAddress;
import java.net.SocketAddress;

public class Main {
    public static String extractClientAddress(SocketAddress remoteAddress) {
        String clientAddress;/*from   ww w .j  ava2  s  .c  o m*/
        if (remoteAddress instanceof InetSocketAddress) {
            clientAddress = ((InetSocketAddress) remoteAddress).getHostName();
        } else {
            clientAddress = remoteAddress.toString();
        }
        return clientAddress;
    }
}

Related

  1. createHttpFields(InetSocketAddress endpoint)
  2. createInetSocketAddress(String address)
  3. createInetSocketAddress(String ip, int port)
  4. describe(InetSocketAddress localAddress)
  5. encodedStringToInetSocketAddress(String str)
  6. extractHostAddr(InetSocketAddress address)
  7. format(final SocketAddress s, final int defaultPort)
  8. formatInetAddr(InetSocketAddress addr)
  9. formatSocketAddress(final InetSocketAddress inetSocketAddress)