Java Socket Address Get getHostName(SocketAddress socketAddress)

Here you can find the source of getHostName(SocketAddress socketAddress)

Description

get Host Name

License

Apache License

Declaration

public static String getHostName(SocketAddress socketAddress) 

Method Source Code


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

Related

  1. getConnString(SocketAddress address)
  2. getDestination(InetSocketAddress server)
  3. getDestinationInetSocketAddress(URI uri, int defaultPort)
  4. getHostAddress(InetSocketAddress addr)
  5. getHostAddress(InetSocketAddress address)
  6. getHostNameNoResolve(InetSocketAddress address)
  7. getHostPortString(InetSocketAddress addr)
  8. getHostPortString(InetSocketAddress addr)
  9. getHostString(InetSocketAddress socketAddress)