【问题标题】:native client curl cannot resolve host本机客户端 curl 无法解析主机
【发布时间】:2015-03-25 09:28:01
【问题描述】:

我正在尝试创建一个 NaCl 模块,该模块将执行 curl 操作。我成功集成了 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)

【问题讨论】:

    标签: curl libcurl google-nativeclient


    【解决方案1】:

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

    【讨论】:

    • 此解决方案在调试时可以使用,但要实际发布此解决方案,您需要将代码作为 Chrome 应用程序运行并请求适当的权限。您可以在 Native Client SDK 中看到这样的示例(例如,examples/api/socket/manifest.json)
    • 谢谢你提供的信息,binji。我去看看。
    猜你喜欢
    • 2018-06-21
    • 1970-01-01
    • 1970-01-01
    • 2014-09-12
    • 1970-01-01
    • 2010-11-23
    • 2011-05-20
    相关资源
    最近更新 更多