code: public static int getAvailablePort(String host, int port, int maxPort) {
          if (isAnyHost(host)
              || isLocalHost(host)
              || isHostInNetworkCard(host)) {
              if (port < MIN_PORT) {
                  port = MIN_PORT;
              }
              for (int i = port; i <= maxPort; i++) {
                  ServerSocket ss = null;
                  try {
                      ss = new ServerSocket();
                      ss.bind(new InetSocketAddress(host, i));
                      if (LOGGER.isDebugEnabled()) {
                          LOGGER.debug("ip:{} port:{} is available", host, i);
                      }
                      return i;
                  } catch (IOException e) {
                      // continue
                      if (LOGGER.isWarnEnabled()) {
                          LOGGER.warn("Can't bind to address [{}:{}], " +
                              "Maybe 1) The port has been bound. " +
                              "2) The network card of this host is not exists or disable. " +
                              "3) The host is wrong.", host, i);
                      }
                      if (LOGGER.isInfoEnabled()) {
                          LOGGER.info("Begin try next port(auto +1):{}", i + 1);
                      }
                  } finally {
                      IOUtils.closeQuietly(ss);
                  }
              }
              throw new SofaRpcRuntimeException("Can't bind to ANY port of " + host + ", please check config");
          } else {
              throw new SofaRpcRuntimeException("The host " + host
                  + " is not found in network cards, please check config");
          }
      }
docs: 检查当前指定端口是否可用，不可用则自动+1再试（随机端口从默认端口开始检查）
  
  @param host    当前ip地址
  @param port    当前指定端口
  @param maxPort 最大端口
  @return 从指定端口开始后第一个可用的端口