initiate a connection to given address

@param string $address either of IPv4:port, hostname:port, [IPv6]:port, unix-path
@return self $this (chainable)
@throws Exception on error
@uses socket_connect()
328058
public function connect($address)
    {
        $ret = @socket_connect($this->resource, $this->unformatAddress($address, $port), $port);
        if ($ret === false) {
            throw Exception::createFromSocketResource($this->resource);
        }
        return $this;
    }
888376
private function connect()
    {

        if ($this->config['host'] && $this->config['port']) {
            // establish the memcache connection
            $this->memcache = new \Memcache;
            $this->memcache->pconnect(
                $this->config['host'],
                $this->config['port']
            );

        } else {
            throw new \Exception('Insufficient connection parameters');
        }
    }
738410
public function bcc($address, $name = null)
    {
        if ($this->arrayOfAddresses($address)) {
            $this->bcc += $this->parseAddresses($address);
        } else {
            $this->bcc[] = [$address, $name];
        }

        return $this;
    }
859662
public function start()
    {
        if (false === ($this->socket = @socket_create(AF_INET, SOCK_STREAM, getprotobyname($this->config['protocol'])))) {
            throw new Exception(sprintf('socket_create(AF_INET, SOCK_STREAM, <%s>) failed: [%d] %s',
                $this->config['protocol'], $code = socket_last_error(), socket_strerror($code)));
        }

        if (false === @socket_bind($this->socket, $this->config['ip'], $this->config['port'])) {
            throw new Exception(sprintf('socket_bind($socket, "%s", %d) failed: [%d] %s',
                $this->config['ip'], $this->config['port'], $code = socket_last_error(), socket_strerror($code)));
        }

        if (false === @socket_getsockname($this->socket, $this->config['ip'], $this->config['port'])) {
            throw new Exception(sprintf('socket_getsockname($socket, "%s", %d) failed: [%d] %s',
                $this->config['ip'], $this->config['port'], $code = socket_last_error(), socket_strerror($code)));
        }

        if (false === @socket_listen($this->socket)) {
            throw new Exception(sprintf('socket_listen($socket) failed: [%d] %s', $code = socket_last_error(), socket_strerror($code)));
        }

        $this->started = true;

        $this->log('Listening for connections on <pop>'.$this.'</pop>', Logger::INFO);
    }
357539
public function connect()
    {
        if ($this->connected) {
            return;
        }

        $this->socket = @fsockopen($this->options['hostname'], $this->options['port'], $errno, $errstr, $this->options['timeout']);
        if (!$this->socket) {
            throw new Exception\IOError($errno.' - '.$errstr);
        }

        $this->connected = true;

        return $this;
    }
1327821
public function address($address = null)
    {
        if ($address !== null) {
            $this->address = str_replace('&amp;', '&', $address);
        }

        $this->setRedirectHeaders();

        return $this->address;
    }
1299440
public function connect()
  {
    if($this->stream !== null) return;

    $host = strval($this->config["host"]);
    $port = strval($this->config["port"]);

    $address = "tcp://" . (strstr($host, ":") !== FALSE ? "[" . $host . "]" : $host) . ":" . $port;
    $options = empty($this->config["tls"]) ? array() : array("ssl" => array("allow_self_signed" => TRUE, "verify_peer" => FALSE, "verify_peer_name" => FALSE));
    $timeout = (int) $this->config["timeout"];

    $this->stream = @stream_socket_client($address, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options));

    if($this->stream === FALSE)
    {
      throw new Exception(Str::factory($errstr)->toUtf8()->toString(), $errno);
    }

    if(!empty($this->config["tls"]))
    {
      stream_socket_enable_crypto($this->stream, TRUE, STREAM_CRYPTO_METHOD_SSLv23_CLIENT);
    }

    @stream_set_timeout($this->stream, $timeout);
    @stream_set_blocking($this->stream, $this->config["blocking"] ? 1 : 0);
  }
1018050
def connect(self):
        """"""
        self.socket = socket.create_connection(self.address, self.timeout)
1349824
public void connect(Object address) throws Exception {

        this.targetAddress = (HttpAddress) address;
        // if we're connecting on an existing SC, then clear it if need be
        // we do not want to clear when the reconnect flag is false because
        // that means we're in the middle of a reconnect (we called this method
        // and not an external user)
        if (null != this.myInterface && isReconnectAllowed()) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Clearing existing OSC on connect");
            }
            this.myInterface.clear();
        }
        super.connect(address);
    }
137917
public function setLocalIpAddress($address)
    {
        if (!filter_var($address, FILTER_VALIDATE_IP)) {
            throw new \InvalidArgumentException('Invalid ip address');
        }

        $this->networkIpVersion = (strpos($address, ':') ===
                                   false) ? NetworkNodeInterface::IP_V4 : NetworkNodeInterface::IP_V6;
        $this->networkLocalIp = $address;
    }
153385
public function connect()
	{
		if ($this->connection)
		{
			return;
		}

		/*
		 * Unlike mysql_connect(), mysqli_connect() takes the port and socket as separate arguments. Therefore, we
		 * have to extract them from the host string.
		 */
		$port = isset($this->options['port']) ? $this->options['port'] : 3306;

		if (preg_match(
			'/^(?P<host>((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:(?P<port>.+))?$/',
			$this->options['host'],
			$matches
			))
		{
			// It's an IPv4 address with or without port
			$this->options['host'] = $matches['host'];

			if (!empty($matches['port']))
			{
				$port = $matches['port'];
			}
		}
		elseif (preg_match('/^(?P<host>\[.*\])(:(?P<port>.+))?$/', $this->options['host'], $matches))
		{
			// We assume square-bracketed IPv6 address with or without port, e.g. [fe80:102::2%eth1]:3306
			$this->options['host'] = $matches['host'];

			if (!empty($matches['port']))
			{
				$port = $matches['port'];
			}
		}
		elseif (preg_match('/^(?P<host>(\w+:\/{2,3})?[a-z0-9\.\-]+)(:(?P<port>[^:]+))?$/i', $this->options['host'], $matches))
		{
			// Named host (e.g example.com or localhost) with or without port
			$this->options['host'] = $matches['host'];

			if (!empty($matches['port']))
			{
				$port = $matches['port'];
			}
		}
		elseif (preg_match('/^:(?P<port>[^:]+)$/', $this->options['host'], $matches))
		{
			// Empty host, just port, e.g. ':3306'
			$this->options['host'] = 'localhost';
			$port = $matches['port'];
		}

		// ... else we assume normal (naked) IPv6 address, so host and port stay as they are or default

		// Get the port number or socket name
		if (is_numeric($port))
		{
			$this->options['port'] = (int) $port;
		}
		else
		{
			$this->options['socket'] = $port;
		}

		// Make sure the MySQLi extension for PHP is installed and enabled.
		if (!static::isSupported())
		{
			throw new \RuntimeException('The MySQLi extension is not available');
		}

		$this->connection = @mysqli_connect(
			$this->options['host'], $this->options['user'], $this->options['password'], null, $this->options['port'], $this->options['socket']
		);

		// Attempt to connect to the server.
		if (!$this->connection)
		{
			throw new \RuntimeException('Could not connect to MySQL.');
		}

		// Set sql_mode to non_strict mode
		mysqli_query($this->connection, "SET @@SESSION.sql_mode = '';");

		// If auto-select is enabled select the given database.
		if ($this->options['select'] && !empty($this->options['database']))
		{
			$this->select($this->options['database']);
		}

		// Set charactersets (needed for MySQL 4.1.2+).
		$this->setUTF();
	}
89410
public function connect(): bool
    {
        if ($this->isConnected()) {
            return true;
        }

        $this->socket = $this->createSocket();
        try {
            if (socket_connect($this->socket, $this->address, $this->port) === false) {
                throw new RelayException(socket_strerror(socket_last_error($this->socket)));
            }
        } catch (\Exception $e) {
            throw new RelayException("unable to establish connection {$this}", 0, $e);
        }

        return true;
    }
183309
public function setCryptoAddress($address)
    {
        if (!$this->checkAddress($address) || !preg_match(static::CRYPTO_ADDRESS_VALIDATION_REGEX, $address)) {
            throw new ErrorParameter('Invalid crypto address provided');
        }

        $this->crypto_address = $address;

        return $this;
    }
657219
public function geolocateIPAddress(AddressInterface $address)
    {
        $result = new GeolocationResult();
        try {
            switch ($address->getRangeType()) {
                case IPRangeType::T_PUBLIC:
                    $addressString = (string) $address;
                    $session = $this->app->make('session');
                    $sessionKey = 'ccm/geolocation/' . $this->geolocator->getGeolocatorHandle() . '/' . $this->geolocator->getGeolocatorID() . '/' . md5(serialize($this->geolocator->getGeolocatorConfiguration())) . '/' . $addressString;
                    if ($session->has($sessionKey)) {
                        $result = $session->get($sessionKey);
                    } else {
                        $result = $this->performGeolocation($address);
                        $session->set($sessionKey, $result);
                    }
                    break;
                default:
                    $result->setError(GeolocationResult::ERR_IPNOTPUBLIC);
                    break;
            }
        } catch (Exception $x) {
            $result->setError(GeolocationResult::ERR_OTHER, '', $x);
        } catch (Throwable $x) {
            $result->setError(GeolocationResult::ERR_OTHER, '', new Exception($x->getMessage(), $x->getCode()));
        }

        return $result;
    }
274553
public static function makeMasternodeResumeInstance(string $address): self
    {
        $transaction = new self();

        $transaction->setVersion(Version::MASTERNODE_RESUME);
        return self::setMasternodeCommandDefaults($address, $transaction);
    }
528733
public function setAddress($address)
    {
        if (null === $address) {
            $this->address = null;
        } elseif ('' == $address) {
            $this->address = '';
        } else {
            $this->assertValidAddress($address);
            $this->address = $address;
        }
        $this->setCachedValue(null);
    }
478560
public function Connect( $Address, $Port, $Timeout = 3, $Engine = self::SOURCE )
		{
			$this->Disconnect( );
			
			if( !is_int( $Timeout ) || $Timeout < 0 )
			{
				throw new InvalidArgumentException( 'Timeout must be an integer.', InvalidArgumentException::TIMEOUT_NOT_INTEGER );
			}
			
			$this->Socket->Open( $Address, (int)$Port, $Timeout, (int)$Engine );
			
			$this->Connected = true;
		}