protected function checkConnection()
    {
        // Setting Connection scheme according ssl support
        if ($this->options['ssl']) {
            if (!extension_loaded('openssl')) {
                // no openssl extension loaded.
                // This is a bit hackisch...
                $this->connection = null;

                throw HTTPException::connectionFailure(
                    $this->options['ip'],
                    $this->options['port'],
                    'ssl activated without openssl extension loaded',
                    0
                );
            }

            $host = 'ssl://'.$this->options['host'];
        } else {
            $host = $this->options['ip'];
        }

        // If the connection could not be established, fsockopen sadly does not
        // only return false (as documented), but also always issues a warning.
        if (($this->connection === null) &&
             (($this->connection = @fsockopen($host, $this->options['port'], $errno, $errstr, $this->options['timeout'])) === false)) {
            // This is a bit hackisch...
            $this->connection = null;
            throw HTTPException::connectionFailure(
                $this->options['ip'],
                $this->options['port'],
                $errstr,
                $errno
            );
        }
    }