A very strange problem with curl

A very strange problem with curl
0.0 0


The tests/CurlTest project in cocos2d-x, I make some small change at CurlTest::ccTouchesEnded()
`CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl)
curl_easy_setopt(curl, CURLOPT_URL, “”);
curl_easy_setopt(curl, CURLOPT_PORT, 9000);
curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
//curl_easy_setopt(m_pCurl, CURLOPT_CONNECTTIMEOUT_MS, 5000);
res = curl_easy_perform(curl);
char msg[100];
if (res == 0)

        CCMessageBox("Connect ok", "Socket");
        sprintf(msg, "Connect error, code:%d", res);
        CCMessageBox(msg, "Socket");

And i run it ok in the windows and android.

And i move CurlTest.cpp and CurlTest.h to my own project from HelloWorld,just add CurlTest layer to the HelloWorld scene,
And i got the right result in windows, there’s a messagebox “Connect ok”,
And i compile and run it in android, the strange problem come out,
It Connect faild, “Connect error, code:7”
The same code at tests/CurlTest run in android is ok
Why my own project connect failed, is there something need to config or difference between tests project with HelloWorld project?

I’m very head pain about this, please help me, thank you!


Did you require the permission of net connection in AndroidMenifest.xml?


Oh, i see, must be this reason,

I will try it later, Thank you very much! This problem almost kill me.

You’d better add this one to the project template default, i think this will help someone like me who didn’t fimilar with android.

Thank you again.:smiley:


OK, it worked.


I don’t think we should add the permission in xml by default, because not all apps need the permission. If the app requires the permission that not needed, it may be rejected by the user.