Associate a reserved TCP port number with this project.

        :param port: TCP port number
359701
def record_tcp_port(self, port):
        

        if port not in self._used_tcp_ports:
            self._used_tcp_ports.add(port)
1234042
function (port, debug) {
  this.port = port || 'tcp://127.0.0.1:13674';
  this.debug = debug || false;
  this.socket = zeromq.socket('router');
  this.socket.identity = 'zmqrpc-'+process.pid;
  this.rpc = undefined;
}
1209223
def remove_tcp_port(self, port):
        

        if port in self._used_tcp_ports:
            self._used_tcp_ports.remove(port)
647677
def tcpip(self, port: int or str = 5555) -> None:
        ''''''
        self._execute('-s', self.device_sn, 'tcpip', str(port))
554506
def add_port(self, port):
        
        self.ports.append(port)
        if port.io_type not in self.port_seqs:
            self.port_seqs[port.io_type] = 0
        self.port_seqs[port.io_type] += 1
        port.sequence = self.port_seqs[port.io_type]
        return self
227385
def add_reserved_switch_binding(switch_ip, state):
    """"""

    # overload port_id to contain switch state
    add_nexusport_binding(
        state,
        const.NO_VLAN_OR_VNI_ID,
        const.NO_VLAN_OR_VNI_ID,
        switch_ip,
        const.RESERVED_NEXUS_SWITCH_DEVICE_ID_R1)
872947
def available_tcp_port(reactor):
    

    endpoint = serverFromString(reactor, 'tcp:0:interface=127.0.0.1')
    port = yield endpoint.listen(NoOpProtocolFactory())
    address = port.getHost()
    yield port.stopListening()
    defer.returnValue(address.port)
43943
void configurePort(String port) {

        if (StringUtils.isNotBlank(port)) {
            try {
                this.port = Integer.parseInt(port);
                log.info("Using port {}", this.port);
            } catch (NumberFormatException e) {
                log.info("Unable to parse server PORT variable ({}). Defaulting to port {}", port, this.port);
            }
        }
    }
1311657
def cmd_port(self, args):
        ''
        if len(args) != 1:
            print("Usage: port <number>")
            return
        
        self.port.close()
        self.portnum = int(args[0])
        self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.port.bind((self.ip, self.portnum))
        self.port.setblocking(0)
        mavutil.set_close_on_exec(self.port.fileno())
        print("Listening for GPS INPUT packets on UDP://%s:%s" % (self.ip, self.portnum))
223850
def allocate_tcp_port():
    """"""
    # We want to bind() the socket but not listen(). Twisted (in
    # tcp.Port.createInternetSocket) would do several other things:
    # non-blocking, close-on-exec, and SO_REUSEADDR. We don't need
    # non-blocking because we never listen on it, and we don't need
    # close-on-exec because we close it right away. So just add SO_REUSEADDR.
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    if platformType == "posix" and sys.platform != "cygwin":
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(("127.0.0.1", 0))
    port = s.getsockname()[1]
    s.close()
    return port
778221
def _fix_port_assignment(self):
        

        port_name = ''
        port_number = None

        if self._port:
            if isinstance(self._port, int):
                port_number = self._port
                port_name = get_port_name(port_number)
            elif isinstance(self._port, string_types):
                port_name = self._port
                port_number = get_port_number(port_name)
            else:
                raise ValueError('Cannot assign port name/number '
                        'based on port assignment type %r' % self._port)

            self._port = port_number
            self._portname = port_name or ''
1371180
def attach_tcp_service(cls, tcp_service: TCPService):
        
        if cls._tcp_service is None:
            cls._tcp_service = tcp_service
            cls._set_bus(tcp_service)
        else:
            warnings.warn('TCP service is already attached')
1296005
def accept(source_port, destination_port, protocol, raw_addresses):
    '''
    
    '''

    protocol = protocol or 'tcp'

    if not isinstance(raw_addresses, list):
        raw_addresses = [raw_addresses]

    addresses = []
    for a in raw_addresses:
        if a is None:
            addresses.append(None)
        else:
            addresses += a.split(',')

    rules = []
    for address in addresses:
        parts = ['-A', CHAIN]

        if address:
            address, _, mask = address.partition('/')
            mask = mask or '32'
            parts.append('-s %s/%s' % (address, mask))

        if source_port:
            parts.append('-p %s -m %s --sport %s' % (protocol, protocol, source_port))

        if destination_port:
            parts.append('-p %s -m %s --dport %s' % (protocol, protocol, destination_port))

        parts += ['-j', 'RETURN']

        rules.append(' '.join(parts))

    return rules
989971
def _get_valid_port(self, port):
        
        if '/' in port:
            port, protocol = port.split('/')
        else:
            protocol = 'tcp'

        try:
            int(port)
        except ValueError:
            raise ValueError("{0} isn't a valid port number.".format(port))

        if protocol not in ('tcp', 'udp'):
            raise ValueError("exposed ports only supports udp or tcp. {0} was passed".format(protocol))

        return "{0}/{1}".format(port, protocol)
807038
def aux(self, aux):
        

        if aux == self._aux:
            return

        if self._aux:
            self._manager.port_manager.release_tcp_port(self._aux, self._project)
            self._aux = None
        if aux is not None:
            self._aux = self._manager.port_manager.reserve_tcp_port(aux, self._project)
            log.info("{module}: '{name}' [{id}]: aux port set to {port}".format(module=self.manager.module_name,
                                                                                name=self.name,
                                                                                id=self.id,
                                                                                port=aux))
1015378
def _next_port(self, port):
        
        port = 5000 + (port + 1) % 1000
        if port == self.port:
            raise DatacatsError('Too many instances running')
        return port
1205012
def new_port():
    """"""
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
    for i in range(12042, 16042):
        try:
            s.bind(('127.0.0.1', i))
            s.close()
            return i
        except socket.error:
            pass
    raise Exception('No local port available')