Connects to the websocket

@return $this
498437
public function initialize()
    {
        try {
            $this->logger->debug('Connecting to the websocket');
            $this->engine->connect();
            $this->logger->debug('Connected to the server');

            $this->isConnected = true;
        } catch (SocketException $e) {
            $this->logger->error('Could not connect to the server', ['exception' => $e]);

            throw $e;
        }

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

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

    if(empty($this->config["ssh"]))
    {
      $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));

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

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

      if(!empty($this->config["tls"]))
      {
        stream_socket_enable_crypto($this->stream, TRUE, STREAM_CRYPTO_METHOD_SSLv23_CLIENT);
      }
    }
    else
    {
      $this->session = @ssh2_connect($host, $port);

      if($this->session === FALSE)
      {
        throw new TeamSpeak3_Transport_Exception("failed to establish secure shell connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "'");
      }

      if(!@ssh2_auth_password($this->session, $this->config["username"], $this->config["password"]))
      {
        throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid loginname or password", 0x208);
      }

      $this->stream = @ssh2_shell($this->session, "raw");

      if($this->stream === FALSE)
      {
        throw new TeamSpeak3_Transport_Exception("failed to open a secure shell on server '" . $this->config["host"] . ":" . $this->config["port"] . "'");
      }
    }

    @stream_set_timeout($this->stream, $timeout);
    @stream_set_blocking($this->stream, $blocking ? 1 : 0);
  }
178975
public static function Connection () {
		\ickx\fw2\router\Router::Connect('/{:controller}/{:action}/{:args}');
		\ickx\fw2\router\Router::Connect('/{:args}');
	}
777778
public function connect(): bool
    {
        if ($this->isConnected()) {
            return true;
        }

        $errno = null;
        $errstr = null;

        // Supress PHP error, we're handling it
        $this->socket = @stream_socket_client(
            $this->getUri(),
            $errno,
            $errstr,
            $this->options['timeout_connect'],
            STREAM_CLIENT_CONNECT,
            $this->getStreamContext()
        );

        if (!$this->socket) {
            throw new \Wrench\Exception\ConnectionException(sprintf(
                'Could not connect to socket: %s (%d)',
                $errstr,
                $errno
            ));
        }

        stream_set_timeout($this->socket, $this->options['timeout_socket']);

        return ($this->connected = true);
    }
15154
private function connect()
    {
        $server = $this->config['server'];
        if (isset($this->config['ssl']) && $this->config['ssl'] == true) {
            $server = 'ssl://' . $server;
        }

        stream_set_blocking(STDIN, 0);
        $this->socket = fsockopen($server, $this->config['port']);

        return (bool) $this->socket;
    }
315057
public function connect(): bool
	{
		if ($this->ssl === true)
		{
			$this->connection = fsockopen('ssl://'.$this->host, $this->port);
		}
		else
		{
			$this->connection = fsockopen($this->host, $this->port);
		}

		return $this->connected();
	}
413392
protected function connect()
    {
        if (!is_object(self::$instance)) {
            self::$instance = new \Memcached();

            if (!empty($this->options['option'])) {
                self::$instance->setOptions($this->options['option']);
            }

            // Set connection timeout ms
            if ($this->options['timeout'] > 0) {
                self::$instance->setOption(\Memcached::OPT_CONNECT_TIMEOUT, $this->options['timeout']);
            }

            // Cluster connections
            $hosts = explode(',', $this->options['host']);
            $ports = explode(',', $this->options['port']);
            if (empty($ports[0])) {
                $ports[0] = 11211;
            }

            // connection establishment
            $servers = [];
            foreach ((array) $hosts as $i => $host) {
                $servers[] = [$host, (isset($ports[$i]) ? $ports[$i] : $ports[0]), 1];
            }

            self::$instance->addServers($servers);

            if ('' != $this->options['username']) {
                self::$instance->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
                self::$instance->setSaslAuthData($this->options['username'], $this->options['password']);
            }
        }
    }
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;
    }
497295
public function connect()
    {
        $this->_service = new SplMemcached();
        $this->_service->addServer($this->_host, $this->_port);
        $stats = $this->_service->getStats();
        if (isset($stats[$this->_host.":".$this->_port])) {
            $this->_connected = true;
        } else {
            throw new ServiceException(
                "Unable to connect to Memcached service"
            );
        }

        return $this;
    }
1261737
public function connect()
    {
        parent::connect();
        $this->resource->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);
        return $this;
    }
951979
protected function startListening()
	{
		foreach ($this->eventsToListenFor as $event) {
			if (is_callable([$this, $event])) {
				$this->connection->eventManager()->bind($event, [$this, $event]);
			}
		}
		return $this;
	}
1358985
private function connect() {
        $connection = fsockopen('tcp://'.$this->options['host'],
                                         $this->options['port'],
                                         $errorCode,
                                         $errorMsg,
                                         $this->options['timeout']);
        // TODO: connect() might hang without producing an error if the connection fails
        if (!$connection) throw new RuntimeException('Could not open socket: '.$errorMsg.' (error '.$errorCode.')');

        $data = stream_get_meta_data($connection);
        if ($data['timed_out']) throw new InfrastructureException('Timeout on socket connection');

        socket_set_timeout($connection, $this->options['timeout']);
        $this->connection = $connection;

        // init connection
        $this->readResponse();                          // read greeting
        $this->writeData('EHLO '.$this->hostName);      // extended "Hello" first
        $response = $this->readResponse();

        $this->parseResponse($response);
        if ($this->responseStatus != 250) {
            $this->writeData('HELO '.$this->hostName);  // regular "Hello" if the extended one fails
            $response = $this->readResponse();

            $this->parseResponse($response);
            if ($this->responseStatus != 250)
                throw new RuntimeException('HELO command not accepted: '.$this->responseStatus.' '.$this->response);
        }
    }
600342
public function connect()
    {
        $connection = $this->_connection;
        $connection->setLogin($this->_config['user']);
        $connection->setPassword($this->_config['password']);
        $connection->setHost($this->_config['host']);
        $connection->setPort($this->_config['port']);
        $connection->setVhost($this->_config['vhost']);
        $connection->setReadTimeout($this->_config['readTimeout']);

        # You shall not use persistent connections
        #
        # AMQPChannelException' with message 'Could not create channel. Connection has no open channel slots remaining
        #
        # The PECL extension is foobar, http://stackoverflow.com/questions/23864647/how-to-avoid-max-channels-per-tcp-connection-with-amqp-php-persistent-connectio
        #

        $connection->connect();
    }
1352927
public function connect()
	{
		if($this->_ssl_mode === true)
		{
			if( ! function_exists('ftp_ssl_connect'))
			{
				throw new \RuntimeException('ftp_ssl_connect() function is missing.');
			}

			$this->_conn_id = @ftp_ssl_connect($this->_hostname, $this->_port, $this->_timeout);
		}

		else
		{
			$this->_conn_id = @ftp_connect($this->_hostname, $this->_port, $this->_timeout);
		}

		if ($this->_conn_id === false)
		{
			if ($this->_debug == true)
			{
				throw new \FtpConnectionException('Unable to establish a connection');
			}
			return false;
		}

		if ( ! $this->_login())
		{
			if ($this->_debug == true)
			{
				throw new \FtpConnectionException('Unable to login');
			}
		}

		// Set passive mode if needed
		if ($this->_passive == true)
		{
			ftp_pasv($this->_conn_id, true);
		}

		return $this;
	}
881078
public function connect()
    {
        if ($this->connection) return $this->connection;

        $driver = $this->getDriver();
        return $this->connection = $driver->connect($this);
    }
351984
public function connect()
    {
        if ($this->connected) {
            return $this;
        }

        # Set that we are connected here, because queries can be run as part of the below code, which would cause an infinite loop
        $this->connected = true;

        switch ($this->mode) {

            case "mysql":
                $this->server = new \Mysqli($this->options["hostname"], $this->options["username"], $this->options["password"]);
                if ($this->server->connect_error) {
                    $this->error();
                }
                if ($this->options["charset"]) {
                    $this->server->set_charset($this->options["charset"]);
                }
                if ($timezone = $this->options["timezone"]) {
                    if ($timezone === self::USE_PHP_TIMEZONE) {
                        $timezone = ini_get("date.timezone");
                    }
                    $this->query("SET time_zone='" . $timezone . "'");
                }
                if ($database = $this->options["database"]) {
                    if (!$this->server->select_db($database)) {
                        $this->error();
                    }
                }
                break;

            case "postgres":
            case "redshift":
                $connect = "host=" . $this->options["hostname"] . " ";
                $connect .= "user=" . $this->options["username"] . " ";
                $connect .= "password=" . $this->options["password"] . " ";
                $connect .= "dbname= " . $this->options["database"] . " ";
                $this->server = pg_connect($connect, PGSQL_CONNECT_FORCE_NEW);
                break;

            case "odbc":
                $this->server = odbc_connect($this->options["hostname"], $this->options["username"], $this->options["password"]);
                break;

            case "sqlite":
                $this->server = new \Sqlite3($this->options["database"]);
                break;

            case "mssql":
                $this->server = mssql_connect($this->options["hostname"], $this->options["username"], $this->options["password"]);
                break;

            case "mssqlsrv":
                if (!$port = $this->options["port"]) {
                    $port = 1433;
                }
                $this->server = sqlsrv_connect("tcp:" . $this->options["hostname"] . ",{$port}", [
                    "Uid"   =>  $this->options["username"],
                    "PWD"   =>  $this->options["password"],
                ]);
                break;
        }

        if (!$this->server) {
            $this->error();
        }

        return $this;
    }
259890
public function connect(): self
    {
        $this->logger->debug('connect to ldap server ['.$this->uri.']', [
            'category' => get_class($this),
        ]);

        if (null === $this->binddn) {
            $this->logger->warning('no binddn set for ldap connection, you should avoid anonymous bind', [
                'category' => get_class($this),
            ]);
        }

        if (false === $this->tls && 'ldaps' !== substr($this->uri, 0, 5)) {
            $this->logger->warning('neither tls nor ldaps enabled for ldap connection, it is strongly reccommended to encrypt ldap connections', [
                'category' => get_class($this),
            ]);
        }

        $this->connection = ldap_connect($this->uri);

        foreach ($this->options as $opt => $value) {
            ldap_set_option($this->connection, constant($opt), $value);
        }

        if (true === $this->tls) {
            ldap_start_tls($this->connection);
        }

        if ($this->connection) {
            if (null !== $this->binddn) {
                $bind = ldap_bind($this->connection, $this->binddn, $this->bindpw);

                if ($bind) {
                    $this->logger->info('bind to ldap server ['.$this->uri.'] with binddn ['.$this->binddn.'] was succesful', [
                        'category' => get_class($this),
                    ]);

                    return $this;
                }

                throw new Exception('failed bind to ldap server, error: '.ldap_error($this->connection));
            }
        } else {
            throw new Exception('failed connect to ldap server '.$this->uri);
        }

        return $this;
    }