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

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

        $address = "tcp://" . $host . ":" . $port;
        $timeout = intval($this->config["timeout"]);

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

        if ($this->stream === false) {
            throw new Ts3Exception(
                StringHelper::factory($errstr)->toUtf8()->toString(),
                $errno
            );
        }

        @stream_set_timeout($this->stream, $timeout);
        @stream_set_blocking($this->stream, $this->config["blocking"] ? 1 : 0);
    }