Sends the remote port mapped for the connection.
        This port is surprisingly often the same as the locally
        bound port for an endpoint because a lot of NAT types
        preserve the port.
492524
def send_remote_port(self):
        
        msg = "REMOTE TCP %s" % (str(self.transport.getPeer().port))
        self.send_line(msg)
1228552
@Override
	public void send( AbstractPacket packet ) throws PacketTransportException
    {
        if (closed)
   			throw new PacketTransportException("Transport is closed");
        
        sender.send(packet);
    }
370377
def send(scope, data):
    
    conn = scope.get('__connection__')
    for line in data:
        conn.send(line)
    return True
84301
def connection_made(self, transport):
        '''
        
        '''

        self.transport = transport
        self.remote_ip, self.port = transport.get_extra_info('peername')[:2]

        logging.debug(
            'Connection made (address: {} port: {})'
            .format(self.remote_ip, self.port))

        self.future = self.send_package(
                protomap.CPROTO_REQ_INFO,
                data=None,
                timeout=10)
119952
def release_port(upnp, external_port):
    
    mapping = upnp.getspecificportmapping(external_port, 'UDP')

    if mapping is None:
        log.error('could not find a port mapping', external=external_port)
        return False
    else:
        log.debug('found existing port mapping', mapping=mapping)

    if upnp.deleteportmapping(external_port, 'UDP'):
        log.info('successfully released port mapping', external=external_port)
        return True

    log.warning(
        'could not release port mapping, check your router for stale mappings',
    )
    return False
837587
def transmitToClient(self, msg: Any, remoteName: str):
        
        payload = self.prepForSending(msg)
        try:
            if isinstance(remoteName, str):
                remoteName = remoteName.encode()
            self.send(payload, remoteName)
        except Exception as ex:
            # TODO: This should not be an error since the client might not have
            # sent the request to all nodes but only some nodes and other
            # nodes might have got this request through PROPAGATE and thus
            # might not have connection with the client.
            logger.error(
                "{}{} unable to send message {} to client {}; Exception: {}" .format(
                    CONNECTION_PREFIX, self, msg, remoteName, ex.__repr__()))
357451
def client_connection_made(self, transport):
        
        with self.lock:
            self.is_closed = False
        self.transport = transport
        self._send_options_message()
1255858
def send(self):
        
        buf_sz = 500
        to_send = {}

        for mn in self.data.iterkeys():
            while len(self.data[mn]) > 0:
                l = len(to_send)
                if l < buf_sz:
                    to_send.setdefault(mn, [])
                    to_send[mn].append(self.data[mn].pop())
                else:
                    try:
                        self._send(to_send)
                        to_send = {}
                        to_send.setdefault(mn, [])
                        to_send[mn].append(self.data[mn].pop())
                    except socket.error:
                        self.logger.error('Error sending to carbon, trying to reconnect.')
                        self.sock = self._connect()

                        # we failed to send, so put it back in the stack and try later
                        for ent in to_send:
                            self.data[ent[0]].append(ent[1])

        try:
            self._send(to_send)
        except socket.error:
            self.logger.error('Error sending to carbon, trying to reconnect.')
            self.sock = self._connect()

        # we failed to send, so put it back in the stack and try later
        for ent in to_send:
            self.data[ent[0]].append(ent[1])
408127
def with_port(self, port):
        
        # N.B. doesn't cleanup query/fragment
        if port is not None and not isinstance(port, int):
            raise TypeError("port should be int or None, got {}".format(type(port)))
        if not self.is_absolute():
            raise ValueError("port replacement is not allowed " "for relative URLs")
        val = self._val
        return URL(
            self._val._replace(
                netloc=self._make_netloc(
                    val.username, val.password, val.hostname, port, encode=False
                )
            ),
            encoded=True,
        )
1046834
public boolean send(Socket socket, int flags)
    {
        Utils.checkArgument(socket != null, "socket parameter must be set");
        return socket.send(data, flags);
    }
283674
async def send(self, config, entry):
        
        if self.endpoint:
            LOGGER.debug("%s -> %s", entry.url, self.url)
            try:
                await self.endpoint.send(config, entry.url, self.url)
            except Exception as err:  # pylint:disable=broad-except
                LOGGER.warning("Ping %s: got %s: %s",
                               self.url, err.__class__.__name__, err)
197996
def connection_made(self, transport):
        '''
        
        '''

        self._connected = True
        self.transport = transport

        self.remote_ip, self.port = transport.get_extra_info('peername')[:2]

        logging.debug(
            'Connection made (address: {} port: {})'
            .format(self.remote_ip, self.port))

        self.auth_future = self.send_package(protomap.CPROTO_REQ_AUTH,
                                             data=(self._username,
                                                   self._password,
                                                   self._dbname),
                                             timeout=10)

        self._password = None
        self.on_connection_made()
365172
async def send(self, metric):
        
        message = json.dumps(metric).encode('utf-8')
        await self.loop.create_datagram_endpoint(
            lambda: UDPClientProtocol(message),
            remote_addr=(self.ip, self.port))
1216467
public void sendMessage(Message message) throws RemoteException
    {
        BaseTransport transport = this.createProxyTransport(SEND_MESSAGE);
        transport.addParam(MESSAGE, message);   // Don't use COMMAND
        transport.sendMessageAndGetReply();
    }
137161
public void bindLocal(DatagramChannel channel, int port) throws IOException {
        // select port if wildcarded
        if (port == PORT_ANY) {
            port = localPortManager.next();
        }

        // try bind
        IOException ex = null;
        for (int q = 0; q < 100; q++) {
            try {
                channel.bind(new InetSocketAddress(localBindAddress, port));
                ex = null;
                break;
            } catch (IOException e) {
                ex = e;
                logger.info("Failed trying to bind " + localBindAddress + ":" + port);
                port = localPortManager.next();
            }
        }

        if (ex != null) {
            throw ex;
        }
    }
1298389
public void send(String nodeID, byte[] packet) {
		if (nodeID == null) {
			logger.warn("Unable to send (missing nodeID)!");
			return;
		}
		if (packet == null || packet.length < 6) {
			logger.warn("Cannot send empty packet to node " + nodeID + "!");
			return;
		}
		SendBuffer buffer = null;
		try {

			// Get or create buffer
			boolean newBuffer = false;
			synchronized (buffers) {
				buffer = buffers.get(nodeID);
				if (buffer == null) {

					// Create new connection
					RemoteAddress address = transporter.getAddress(nodeID);
					if (address == null) {
						logger.warn("Unknown node ID (" + nodeID + ")!");
						return;
					}
					buffer = new SendBuffer(nodeID, address.host, address.port, debug);
					append(nodeID, buffer, packet);
					buffers.put(nodeID, buffer);
					newBuffer = true;
				} else {

					// Try to append to buffer
					if (!buffer.append(packet)) {

						// Buffer is closed
						RemoteAddress address = transporter.getAddress(nodeID);
						buffer = new SendBuffer(nodeID, address.host, address.port, debug);
						append(nodeID, buffer, packet);
						buffers.put(nodeID, buffer);
						newBuffer = true;
					}
				}
			}
			if (newBuffer) {

				// Close older connections
				if (maxConnections > 0) {
					cleanup();
				}

				// Add to opened buffers
				opened.add(buffer);

			} else if (buffer.key != null) {

				// Mark as writable
				buffer.key.interestOps(SelectionKey.OP_WRITE);
			}

			// Wake up selector
			if (selector != null) {
				selector.wakeup();
			}

		} catch (Throwable cause) {
			synchronized (buffers) {
				buffers.remove(nodeID);
			}
			LinkedList<byte[]> packets;
			if (buffer != null) {
				packets = buffer.getUnsentPackets();
			} else {
				packets = new LinkedList<>();
			}
			if (packets.isEmpty() && packet != null) {
				packets.addLast(packet);
			}
			transporter.unableToSend(nodeID, packets, cause);
		}
	}
1182882
def respond(self, packet, peer, flags=0):
        
        self.sock.sendto(packet, flags, peer)