curl - Couldn't connect to server

Got “Couldn’t connect to server” after running some time

curl = curl_easy_init();

if(curl) {

curl_easy_setopt( curl , CURLOPT_URL, “http://~~.php” ) ;

html_context_data data = {0, 0};

curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, callback_write_memory );

curl_slist* header = NULL ;
header = curl_slist_append(header, “Content-Type: application/x-www-form-urlencoded”);
curl_easy_setopt( curl , CURLOPT_HTTPHEADER , header ) ;

memset(buffer, 0, 128);
sprintf(buffer, “test=%s”, txt->getString());
curl_easy_setopt( curl , CURLOPT_POSTFIELDS , buffer ) ;
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(buffer));

curl_easy_setopt( curl , CURLOPT_POST , 1 ) ;

// 사이트 실제 처리 요청
CURLcode rc = curl_easy_perform( curl ) ;
if( CURLE_OK != rc ){

free_html_context_data( &data );

curl_slist_free_all( header ) ;

curl_easy_cleanup( curl ) ;

CCMessageBox(curl_easy_strerror( rc ), “”);

return ;
}

// html 리턴 코드 보기
long statLong;
curl_easy_getinfo( curl, CURLINFO_HTTP_CODE, &statLong);

if(200 != statLong)
{

// 사용한 메모리 해제
free_html_context_data( &data );

// 헤더 리스트 해제
curl_slist_free_all( header ) ;
// context 해제
curl_easy_cleanup( curl ) ;

return ;
}

if(strcmp(data.data, “–2”) == 0)
{

free_html_context_data( &data );

curl_slist_free_all( header ) ;

curl_easy_cleanup( curl ) ;
return ;
}

free_html_context_data( &data );

curl_slist_free_all( header ) ;

curl_easy_cleanup( curl ) ;

refer to http://cocos2d-x.org/boards/6/topics/11703