Java Socket Address Get isLegalPeerAddress(@CheckForNull SocketAddress socketAddress)

Here you can find the source of isLegalPeerAddress(@CheckForNull SocketAddress socketAddress)

Description

is Legal Peer Address

License

Apache License

Declaration

@Deprecated 
    public static boolean isLegalPeerAddress(@CheckForNull SocketAddress socketAddress) 

Method Source Code


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

import java.net.InetAddress;
import java.net.InetSocketAddress;

import java.net.SocketAddress;

import javax.annotation.CheckForNull;

public class Main {
    @Deprecated // Not happy with this yet.
    public static boolean isLegalPeerAddress(@CheckForNull SocketAddress socketAddress) {
        if (socketAddress == null)
            return false;
        if (socketAddress instanceof InetSocketAddress) {
            InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
            InetAddress inetAddress = inetSocketAddress.getAddress();
            if (inetAddress == null)
                return false;
            if (inetAddress.isAnyLocalAddress())
                return false;
            if (inetAddress.isLoopbackAddress())
                return false;
            if (inetAddress.isMulticastAddress())
                return false;
        }//from  w  w w.ja  v  a2s . c  o m
        return true;
    }
}

Related

  1. getSocketConnectString( InetSocketAddress socketAddress)
  2. inetAddrToHoman(final InetSocketAddress sockAddr)
  3. inetSocketAddress2IpPort(InetSocketAddress addr)
  4. IpToString(InetSocketAddress address)
  5. isAddressDefined(InetSocketAddress address)
  6. isLocalAddress(Socket socket)
  7. isSameAddress(SocketAddress a1, SocketAddress a2)
  8. isUdpPortAvailable(InetSocketAddress localAddress)
  9. isUnresolved(SocketAddress address)