本机客户端curl无法解析主机

时间:2015-03-25 09:28:01

标签: curl libcurl google-nativeclient

我试图创建一个NaCl模块,它将执行卷曲操作。我成功地集成了naclports curl库,编写了一个非常简单的模块并将其托管在本地服务器上,但无法使curl正常工作。当我访问该模块时(在Chrome 41上),我总是会遇到以下错误序列:

Rebuilt URL to: http://www.google.com/
localhost/:1 * timeout on name lookup is not supported
localhost/:1 * Hostname was NOT found in DNS cache
localhost/:1 * Curl_ipv4_resolve_r failed for www.google.com
localhost/:1 * Couldn't resolve host 'www.google.com'
localhost/:1 * Closing connection 0

的main.cpp

#include <ppapi_simple/ps_main.h>
#include <iostream>
#include <unistd.h>
#include "include/curl/curl.h"

int ppapi_simple_main(int argc,char* argv[]){
    CURL* curl;
    CURLcode res;
    curl=curl_easy_init();
    if(curl){
        curl_easy_setopt(curl,CURLOPT_URL,"http://www.google.com");
        curl_easy_setopt(curl,CURLOPT_VERBOSE,1L);

        res=curl_easy_perform(curl);

        curl_easy_cleanup(curl);
    }
    return 0;

}

PPAPI_SIMPLE_REGISTER_MAIN(ppapi_simple_main)

1 个答案:

答案 0 :(得分:2)

原来解决方案很简单。我只需要使用--allow-nacl-socket-api = localhost标志运行chrome。