Adds an outbound connection to the network.

        Args:
            uri (str): The zmq-style (e.g. tcp://hostname:port) uri
                to attempt to connect to.
975163
def add_outbound_connection(self, uri):
        
        LOGGER.debug("Adding connection to %s", uri)
        conn = OutboundConnection(
            connections=self._connections,
            endpoint=uri,
            dispatcher=self._dispatcher,
            zmq_identity=self._zmq_identity,
            secured=self._secured,
            server_public_key=self._server_public_key,
            server_private_key=self._server_private_key,
            future_callback_threadpool=self._future_callback_threadpool,
            heartbeat=True,
            connection_timeout=self._connection_timeout)

        self.outbound_connections[uri] = conn
        conn.start()

        self._add_connection(conn, uri)

        connect_message = ConnectionRequest(endpoint=self._public_endpoint)
        conn.send(
            validator_pb2.Message.NETWORK_CONNECT,
            connect_message.SerializeToString(),
            callback=partial(
                self._connect_callback,
                connection=conn,
            ))

        return conn
131723
public Set<ServerSentEventConnection> getConnections(String uri) {
        Objects.requireNonNull(uri, Required.URI.toString());

        final Set<ServerSentEventConnection> uriConnections = this.cache.get(Default.SSE_CACHE_PREFIX.toString() + uri);

        return (uriConnections == null) ? new HashSet<>() : uriConnections;
    }
69948
def do_http(uri, request)
      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = true
      # Let then know about us
      request['User-Agent'] = 'SlackRubyAPIWrapper'
      begin
        http.request(request)
      rescue OpenSSL::SSL::SSLError => e
        raise Slack::Error, 'SSL error connecting to Slack.'
      end
    end
1215389
def join_uri(scheme, userinfo, host, port, registry, path, opaque, query, fragment)
      URI::Generic.new(scheme, userinfo, host, port, registry, path, opaque, query, fragment).to_s
    end
2863
function Connection(uri) {
    this.channels = {};
    let version = require('../package.json').version;
    let opts = {
        query: 'instanceId=' + 'js_cli_' + version,
        'sync disconnect on unload': true,
        path: '/syncsocket'
    };
    this.socket = io.connect(uri, opts);
    this.bindEvents();
}
1276092
public void setConnections(String uri, Set<ServerSentEventConnection> uriConnections) {
        Objects.requireNonNull(uri, Required.URI.toString());
        Objects.requireNonNull(uriConnections, Required.URI_CONNECTIONS.toString());

        this.cache.put(Default.SSE_CACHE_PREFIX.toString() + uri, uriConnections);
    }
1356792
def _get_connection(self, uri, headers=None):
    
    connection = None
    if uri.scheme == 'https':
      if not uri.port:
        connection = httplib.HTTPSConnection(uri.host)
      else:
        connection = httplib.HTTPSConnection(uri.host, int(uri.port))
    else:
      if not uri.port:
        connection = httplib.HTTPConnection(uri.host)
      else:
        connection = httplib.HTTPConnection(uri.host, int(uri.port))
    return connection
1330643
private <T> HttpResponse sendRequest(final URI uri, final HttpRequest<T> request) throws IOException, ProtocolException
	{
		final HttpURLConnection connection;
		try
		{
			connection = mConnectionFactory.httpUrlConnection(uri);
		}
		catch (IllegalArgumentException e)
		{
			throw new ProtocolException("The given URI is not applicable to HTTP requests.", e);
		}
		// ensure the expected redirect behavior
		connection.setInstanceFollowRedirects(false);
		// set the request method
		connection.setDoOutput(request.method().supportsRequestPayload());
		connection.setRequestMethod(request.method().verb());
		// add all headers
		for (Header<?> header : request.headers())
		{
			connection.setRequestProperty(header.type().name(), header.toString());
		}
		// also set the content-type header if we have any content-type
		if (request.requestEntity().contentType() != null)
		{
			connection.setRequestProperty(HttpHeaders.CONTENT_TYPE.name(), HttpHeaders.CONTENT_TYPE.valueString(request.requestEntity().contentType()));
		}
		// send the request entity if applicable
		if (request.method().supportsRequestPayload())
		{
			OutputStream out = connection.getOutputStream();
			try
			{
				request.requestEntity().writeContent(out);
			}
			finally
			{
				out.close();
			}
		}
		// return the response
		return new HttpUrlConnectionResponse(uri, connection);
	}
191134
def _connected(self, link_uri):
        
        print('Connected to %s' % link_uri)

        self._cf.packet_received.add_callback(self._got_packet)
994880
def get_by_uri(self, uri):
        
        self._helper.validate_resource_uri(uri)
        data = self._helper.do_get(uri)

        if data:
            new_resource = self.new(self._connection, data)
        else:
            new_resource = None

        return new_resource
493154
def get_port(self, id_or_uri, port_id_or_uri):
        
        uri = self._client.build_subresource_uri(id_or_uri, port_id_or_uri, "ports")
        return self._client.get(uri)
191162
public static String modifyURIPort(String uri, int newPort) {
        try {
            URI uriObj = new URI(uri);
            return uriToString(URLUtils.modifyURIPort(uriObj, newPort));
        }
        catch (URISyntaxException e) {
            try {
                return (new NetworkInterfaceURI(uri)).modifyURIPort(newPort);
            }
            catch (IllegalArgumentException ne) {
                throw new IllegalArgumentException(ne.getMessage(), ne);
            }
        }
    }
45619
public void setOutboundInterface(SipURI outboundInterface) {
		if(!isValid()) {
			throw new IllegalStateException("the session has been invalidated");
		}
		if(outboundInterface == null) {
			throw new NullPointerException("parameter is null");
		}
		List<SipURI> list = sipFactory.getSipNetworkInterfaceManager().getOutboundInterfaces();
		SipURI networkInterface = null;
		for(SipURI networkInterfaceURI : list) {
			if(networkInterfaceURI.equals(outboundInterface)) {
				networkInterface = networkInterfaceURI;
				break;
			}
		}

		if(networkInterface == null) throw new IllegalArgumentException("Network interface for " +
				outboundInterface + " not found");
		this.outboundInterface = outboundInterface.toString();
		if(outboundInterface.getTransportParam() != null) {
			this.transport = outboundInterface.getTransportParam();
		}
	}
995307
def _acquire_connection(self, host, port, use_ssl=False, tunnel=True):
        ''''''
        if hasattr(self._connection_pool, 'acquire_proxy'):
            connection = yield from \
                self._connection_pool.acquire_proxy(host, port, use_ssl,
                                                    tunnel=tunnel)
        else:
            connection = yield from \
                self._connection_pool.acquire(host, port, use_ssl)

        self._connections.add(connection)

        return connection
404438
public void setOutboundInterface(SipURI outboundInterface) {
		if(outboundInterface == null) {
			throw new NullPointerException("outbound Interface param shouldn't be null");
		}
		List<SipURI> list = this.sipFactoryImpl.getSipNetworkInterfaceManager().getOutboundInterfaces();
		SipURI networkInterface = null;
		for(SipURI networkInterfaceURI : list) {
			if(networkInterfaceURI.equals(outboundInterface)) {
				networkInterface = networkInterfaceURI;
				break;
			}
		}
		
		if(networkInterface == null) throw new IllegalArgumentException("Network interface for " +
				outboundInterface + " not found");		
		
		this.outboundInterface = networkInterface;
	}
735808
def beanstalk_host_and_port(uri_string)
      uri = URI.parse(uri_string)
      raise(BadURL, uri_string) if uri.scheme != 'beanstalk'.freeze
      "#{uri.host}:#{uri.port || 11300}"
    end
16112
def requestConnection(self, wanInterfaceId=1, timeout=1):
        
        namespace = Wan.getServiceType("requestConnection") + str(wanInterfaceId)
        uri = self.getControlURL(namespace)

        self.execute(uri, namespace, "RequestConnection", timeout=timeout)