public function read($length = 1024)
    {
        if (!$this->connected && !$this->connect()) {
            return false;
        }

        if (!feof($this->connection)) {
            $buffer = fread($this->connection, $length);
            $info = stream_get_meta_data($this->connection);
            if ($info['timed_out']) {
                $this->setLastError(E_WARNING, 'Connection timed out');

                return false;
            }

            return $buffer;
        }

        return false;
    }