private function doRequest($cmd, $args = array())
    {
        clearstatcache();
        $args['domain'] = $this->domain;
        $params = http_build_query($args);

        $this->connect();

        fwrite($this->socket, "{$cmd} {$params}\n");
        $line = fgets($this->socket);

        $words = explode(' ', $line);

        if ($words[0] == 'OK') {
            parse_str(trim($words[1]), $result);
        } else {
            $errorName = empty($words[1]) ? null : $words[1];

            switch ($errorName) {
                case 'unknown_key':
                    $errorCode = static::ERR_UNKNOWN_KEY;
                    break;
                case 'empty_file':
                    $errorCode = static::ERR_EMPTY_FILE;
                    break;
                case 'none_match':
                    $errorCode = static::ERR_NONE_MATCH;
                    break;
                case 'key_exists':
                    $errorCode = static::ERR_KEY_EXISTS;
                    break;
                default:
                    $errorCode = static::ERR_OTHER;
            }

            throw new \RuntimeException(
                sprintf('Error response: %s', $line),
                $errorCode
            );
        }

        return $result;
    }