2015-03-25 56 views
0

我正在嘗試創建一個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

原來的解決方案很簡單。我只需要使用--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

相關問題