Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/147.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
curl_easy_perform()失败:无法';无法连接到服务器 >我使用LIcCURL和C++来对页面中的数据进行重新排序,但是由于某些原因,当我连接到VPS时,它会在帖子标题中引发错误。vps中的代码只是发出get请求并从我的数据库中吐出一些数据 #include "requestMapper.hpp" // Send a GET request to API to retreive image void RequestMapper::retreiveData(std::string url) { CURL *curl; CURLcode res; curl_global_init(CURL_GLOBAL_DEFAULT); curl = curl_easy_init(); if(curl) { ISSUE HERE // curl_easy_setopt(curl, CURLOPT_URL, "https://104.236.200.91/index.php/food/"); res = curl_easy_perform(curl); #ifdef SKIP_PEER_VERIFICATION curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); #endif #ifdef SKIP_HOSTNAME_VERIFICATION curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); #endif res = curl_easy_perform(curl); if (res != CURLE_OK) fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); curl_easy_cleanup(curl); } curl_global_cleanup(); } // Submit a post request to API link to send data void RequestMapper::postData() { } int main(void) { RequestMapper rm; rm.retreiveData("sample"); return 0; }_C++_Libcurl - Fatal编程技术网

curl_easy_perform()失败:无法';无法连接到服务器 >我使用LIcCURL和C++来对页面中的数据进行重新排序,但是由于某些原因,当我连接到VPS时,它会在帖子标题中引发错误。vps中的代码只是发出get请求并从我的数据库中吐出一些数据 #include "requestMapper.hpp" // Send a GET request to API to retreive image void RequestMapper::retreiveData(std::string url) { CURL *curl; CURLcode res; curl_global_init(CURL_GLOBAL_DEFAULT); curl = curl_easy_init(); if(curl) { ISSUE HERE // curl_easy_setopt(curl, CURLOPT_URL, "https://104.236.200.91/index.php/food/"); res = curl_easy_perform(curl); #ifdef SKIP_PEER_VERIFICATION curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); #endif #ifdef SKIP_HOSTNAME_VERIFICATION curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); #endif res = curl_easy_perform(curl); if (res != CURLE_OK) fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); curl_easy_cleanup(curl); } curl_global_cleanup(); } // Submit a post request to API link to send data void RequestMapper::postData() { } int main(void) { RequestMapper rm; rm.retreiveData("sample"); return 0; }

curl_easy_perform()失败:无法';无法连接到服务器 >我使用LIcCURL和C++来对页面中的数据进行重新排序,但是由于某些原因,当我连接到VPS时,它会在帖子标题中引发错误。vps中的代码只是发出get请求并从我的数据库中吐出一些数据 #include "requestMapper.hpp" // Send a GET request to API to retreive image void RequestMapper::retreiveData(std::string url) { CURL *curl; CURLcode res; curl_global_init(CURL_GLOBAL_DEFAULT); curl = curl_easy_init(); if(curl) { ISSUE HERE // curl_easy_setopt(curl, CURLOPT_URL, "https://104.236.200.91/index.php/food/"); res = curl_easy_perform(curl); #ifdef SKIP_PEER_VERIFICATION curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); #endif #ifdef SKIP_HOSTNAME_VERIFICATION curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); #endif res = curl_easy_perform(curl); if (res != CURLE_OK) fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); curl_easy_cleanup(curl); } curl_global_cleanup(); } // Submit a post request to API link to send data void RequestMapper::postData() { } int main(void) { RequestMapper rm; rm.retreiveData("sample"); return 0; },c++,libcurl,C++,Libcurl,当url类似于“”时,此代码工作正常,但当我点击指向我的web服务器的链接时,我设置了该错误。我是这个图书馆的新手,但我认为我做的事情是正确的。如果有人有任何见解,请让我知道!我将继续对此进行修补,如果我找到了解决方案,我将在这里分享 谢谢 编辑: 我最近解决了这个问题,并想与任何可能偶然发现这篇文章的人分享。 我正在使用https://URL当我应该使用http://URL因此,如果遇到此问题,请先尝试使用它 这是错误7,“无法连接到主机”,如下所示: 无法连接到主机。curl设法获得了到的I

当url类似于“”时,此代码工作正常,但当我点击指向我的web服务器的链接时,我设置了该错误。我是这个图书馆的新手,但我认为我做的事情是正确的。如果有人有任何见解,请让我知道!我将继续对此进行修补,如果我找到了解决方案,我将在这里分享

谢谢

编辑:

我最近解决了这个问题,并想与任何可能偶然发现这篇文章的人分享。 我正在使用
https://URL
当我应该使用
http://URL
因此,如果遇到此问题,请先尝试使用它

这是错误7,“无法连接到主机”,如下所示:

无法连接到主机。curl设法获得了到的IP地址 计算机,它试图设置到主机的TCP连接,但失败。 这可能是因为您指定了错误的端口号 错误的主机名、错误的协议,或者可能是因为存在 防火墙或介于两者之间的其他网络设备,阻止 交通堵塞