libnative客户端curl无法解析主机



我正在尝试创建一个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)

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

相关内容

最新更新