Get the ntp server port
179147
def _get_service_port(self, instance):
        
        host = instance.get('host', DEFAULT_HOST)
        port = instance.get('port', DEFAULT_PORT)
        # default port is the name of the service but lookup would fail
        # if the /etc/services file is missing. In that case, fallback to numeric
        try:
            socket.getaddrinfo(host, port)
        except socket.gaierror:
            port = DEFAULT_PORT_NUM

        return port
368871
def get_port_monitor(self):
        
        uri = "{}{}".format(self.data["uri"], self.PORT_MONITOR_PATH)
        return self._helper.do_get(uri)
1055407
def get_port_by_name(self, port_name):
        ''''''
        with self._mutex:
            for p in self.ports:
                if p.name == port_name:
                    return p
            return None
113870
def server_bind(self):
    """"""
    TCPServer.server_bind(self)
    _, self.server_port = self.socket.getsockname()[:2]
796017
public static int getAvailablePort() {
		for (int i = 0; i < 50; i++) {
			try (ServerSocket serverSocket = new ServerSocket(0)) {
				int port = serverSocket.getLocalPort();
				if (port != 0) {
					return port;
				}
			}
			catch (IOException ignored) {}
		}

		throw new RuntimeException("Could not find a free permitted port on the machine.");
	}
82103
private Integer getPort(String resourcePath, FtpEndpointConfiguration endpointConfiguration) {
        if (resourcePath.contains(":")) {
            return Integer.valueOf(resourcePath.split(":")[1]);
        }

        return endpointConfiguration.getPort();
    }
280806
def detect_port(port):
    ''''''
    socket_test = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    try:
        socket_test.connect(('127.0.0.1', int(port)))
        socket_test.close()
        return True
    except:
        return False
925351
def get_ntp_peers(self):
        """"""
        ntp_stats = self.get_ntp_stats()

        return {
            ntp_peer.get("remote"): {}
            for ntp_peer in ntp_stats
            if ntp_peer.get("remote")
        }
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;
    }
1312712
def getVersionNumber(self):
        """"""
        print '%s call getVersionNumber' % self.port
        versionStr = self.__sendCommand(WPANCTL_CMD + 'getprop -v NCP:Version')[0]

        return self.__stripValue(versionStr)
137657
def find_port(addr, user):
    """"""
    import pwd
    home = pwd.getpwuid(os.getuid()).pw_dir
    for name in os.listdir('%s/.ssh/' % home):
        if name.startswith('unixpipe_%s@%s_' % (user, addr,)):
            return int(name.split('_')[2])
408121
def portMapping(nport,proto)
            checkProto(proto)
            checkPort(nport)
            if nport.to_i == 0 then
                raise ArgumentError, "Port must be an int value and greater then 0."
            end
            joinThread()
            client = getCString()
            lport = getCString()
            if MiniUPnP.UPNP_GetSpecificPortMappingEntry(@urls.controlURL,
                                     @data.servicetype, nport.to_s,proto,
                                     client,lport) != 0 then
                raise UPnPException.new, "Error while retriving the port mapping."
            end
            return client.rstrip, lport.rstrip.to_i
        end
198013
def get_ntp_peers(self):
        """"""
        ntp_table = junos_views.junos_ntp_peers_config_table(self.device)
        ntp_table.get()

        ntp_peers = ntp_table.items()

        if not ntp_peers:
            return {}

        return {napalm_base.helpers.ip(peer[0]): {} for peer in ntp_peers}
781981
def _get_ipv4_from_binary(self, bin_addr):
        """"""

        return socket.inet_ntop(socket.AF_INET, struct.pack("!L", bin_addr))
299485
def _connect_nntp (self, nntpserver):
        
        tries = 0
        nntp = None
        while tries < 2:
            tries += 1
            try:
                nntp = nntplib.NNTP(nntpserver, usenetrc=False)
            except nntplib.NNTPTemporaryError:
                self.wait()
            except nntplib.NNTPPermanentError as msg:
                if re.compile("^50[45]").search(str(msg)):
                    self.wait()
                else:
                    raise
        if nntp is None:
            raise LinkCheckerError(
               _("NNTP server too busy; tried more than %d times.") % tries)
        if log.is_debug(LOG_CHECK):
            nntp.set_debuglevel(1)
        self.add_info(nntp.getwelcome())
        return nntp
896422
def find_free_port():
    """"""
    with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
        sock.bind(('', 0))
        return sock.getsockname()[1]
1192822
def get_available_port
      server = TCPServer.open(0)
      saddr = server.getsockname
      port = Socket.unpack_sockaddr_in(saddr)[0]
      server.close
      port
    end