Gets the port that JMXetric will announce to, this is usually the port
gmond is running on

@return port number, defaults to 8649
163574
private int getPort() {
		String port = getGangliaConfig(args.getPort(), ganglia, "port",
				DEFAULT_PORT);
		return Integer.parseInt(port);
	}
347104
private static int getOpenPort() throws IOException {
        Log.info(c, "getOpenPort", "Entry.");
        ServerSocket s = new ServerSocket(0);
        Log.info(c, "getOpenPort", "Got socket.");
        int port = s.getLocalPort();
        Log.info(c, "getOpenPort", "Got port " + s);
        s.close();
        Log.info(c, "getOpenPort", "Close socket");
        return port;
    }
960240
private String configureHttpPort() {
        String result;
        result = String.format(
                "sudo sed -i 's@Listen[ 0-9]\\+@Listen %s@g' %s/ports.conf",
                getEntity().getHttpPort(),
                getEntity().getConfigurationDir()
        );
        return result;
    }
574026
protected function getPortForBuild()
	{
		if ( !$this->getPort() ) {
			return '';
		}

		$default_ports = array('http' => 80, 'https' => 443);

		if ( $this->getPort() === $default_ports[$this->getProtocol()] ) {
			return '';
		}

		return ':' . $this->getPort();
	}
222188
public function getPort(): ? int
    {
        if ( $this->port === null ) {
            return self::DEFAULT_PORTS[$this->scheme ?? ''] ?? null;
        }

        return $this->port;
    }
608408
public static String getLocalHostPort() {
        String defaultPort = SystemPropertiesUtils.getSystemProperty(
                NaviCommonConstant.SYSTEM_PROPERTY_SERVER_PORT_FROM_SLASH_D_4JPAAS1,
                NaviCommonConstant.SYSTEM_PROPERTY_SERVER_PORT_FROM_ENV_4JPAAS1, ""
                        + RpcServerConf.SERVER_PORT);
        return SystemPropertiesUtils.getSystemProperty(
                NaviCommonConstant.SYSTEM_PROPERTY_SERVER_PORT_FROM_ENV_4JPAAS2, defaultPort);
    }
1120883
public int getPort()
    {
        if (_port > 0) return _port;
        if (_host != null) return 0;
        if (_uri.isAbsolute())
            _port = _uri.getPort();
        else if (_connection != null) _port = _connection.getServerPort();
        return _port;
    }
895033
public String getChainName()
   {
      if (mode != PropertiesType.HOST_PORT)
      {
         throw new SIErrorException(
            nls.getFormattedMessage("INVALID_METHOD_FOR_OBJECT_TYPE_SICO0006", null, "INVALID_METHOD_FOR_OBJECT_TYPE_SICO0006")  // D270373
         );
      }

      return endPoint.getChain();
   }
1216948
public static Integer getPort(String resourcePath, RmiEndpointConfiguration endpointConfiguration) {
        if (resourcePath.contains(":")) {
            String portSpec = resourcePath.split(":")[1];

            if (portSpec.contains("/")) {
                portSpec = portSpec.substring(0, portSpec.indexOf('/'));
            }

            return Integer.valueOf(portSpec);
        }

        return endpointConfiguration.getPort();
    }
1105033
public function getServerPort()
    {
        if (!$this->port) {
            $default = $this->isSecure() ? 443 : 80;
            $this->setServerPort($this->getServer('SERVER_PORT', $default));
        }
        return $this->port;
    }
215190
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");
        }
    }
643151
@Override
  protected int getDefaultPort() {
    logger.atFine().log("GHFS.getDefaultPort:");
    int result = -1;
    logger.atFine().log("GHFS.getDefaultPort:=> %s", result);
    return result;
  }
189870
private String hostAndPort() {
        int start = url.indexOf("://") + 3;
        int end = url.indexOf("/", start);
        return url.substring(start, end);
    }
916397
public function getServerPort()
    {
        return isset($this->swooleRequest->server['SERVER_PORT']) ? (int) $this->swooleRequest->server['SERVER_PORT'] : null;
    }
853605
public int getRemotePort() {
		int port = -1;

		if(getTransaction() != null) {
			if(((SIPTransaction)getTransaction()).getPeerPacketSourceAddress() != null) {
				port = ((SIPTransaction)getTransaction()).getPeerPacketSourcePort();
			} else {
				port = ((SIPTransaction)getTransaction()).getPeerPort();
			}
		} else {
			ViaHeader via = (ViaHeader) message.getHeader(ViaHeader.NAME);
			// https://code.google.com/p/sipservlets/issues/detail?id=137
            boolean isExternal = sipFactoryImpl.getSipApplicationDispatcher().isViaHeaderExternal(via);
            if(message instanceof Request && !isExternal) {
                // locally generated messages should return -1 as per Javadoc
                return -1;
            }
			if(via != null) {
				port = via.getPort();
			}
		}
		if(port<=0) {
			return 5060;
		}
		else {
			return port;
		}
	}
290939
public function getPort()
    {
        if (null !== $this->port) {
            return $this->port;
        }

        $tmp = parse_url($this->getUrl());
        if (isset($tmp['port'])) {
            $this->setPort($tmp['port']);
        } elseif (isset($tmp['scheme'])) {
            $this->setPort(self::$defaultPorts[$tmp['scheme']]);
        }

        return $this->port;
    }
10306
public static function serverPort()
    {
        if ( empty( $GLOBALS['eZSysServerPort'] ) )
        {
            $hostname = self::hostname();
            if ( preg_match( "/.*:([0-9]+)/", $hostname, $regs ) )
            {
                $port = (int) $regs[1];
            }
            else
            {
                $port = (int) self::serverVariable( 'SERVER_PORT', true );
            }

            if ( !$port )
            {
                $port = 80;
            }

            $GLOBALS['eZSysServerPort'] = $port;
        }
        return $GLOBALS['eZSysServerPort'];
    }