public static Keeper isPortKeepable(final int port, int protocol, InetAddress addr) {
    if (protocol == SOCKET) {
      // Try to create a ServerSocket
      if (addr == null) {
        return keepAllInterfaces(port);
      } else {
        return keepOneInterface(addr, port);
      }
    } else if (protocol == MULTICAST) {
      throw new IllegalArgumentException("You can not keep the JGROUPS protocol");
    } else {
      throw new IllegalArgumentException(String.format("Unknown protocol: %d", protocol));
    }
  }
Returns whether or not the given port on the local host is available (that is, unused).

@param port The port to check
@param protocol The protocol to check (either {@link #SOCKET} or {@link #MULTICAST}).
@param addr the bind address (or mcast address) to use
@throws IllegalArgumentException <code>protocol</code> is unknown
geode-membership/src/main/java/org/apache/geode/internal/membership/utils/AvailablePort.java