本地客户端卷曲无法解析主机

问题描述:

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

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

+0

该解决方案在调试时可以正常工作,但实际上需要将代码作为Chrome应用运行并请求适当的权限。您可以在Native Client SDK中查看这些示例(例如examples/api/socket/manifest.json) – binji 2015-03-25 16:17:02

+0

感谢您提供的信息binji。我会看一看。 – rok 2015-03-26 08:58:04