1

Here the output is supposed to be anything but 0.

Because 0 according to libcurl documentation is a success. http://curl.haxx.se/libcurl/c/libcurl-errors.html

curl_easy_setopt(curl_handle, CURLOPT_PROXY, "socks5://127.0.0.1:9050");

And clearly curl_easy_setopt is supposed to return 5 i.e CURLE_COULDNT_RESOLVE_PROXY

#include <iostream>
#include <string>
#include <curl/curl.h>
using namespace std;
int main()
{
    CURL *curl_handle;
    CURLcode err;
    curl_global_init(CURL_GLOBAL_ALL);
    curl_handle = curl_easy_init();
    err = curl_easy_setopt(curl_handle, CURLOPT_PROXY, "socks5://127.0.0.1:9050");
    cout << err;
}

Am i missing something here ?

MPelletier
  • 16,256
  • 15
  • 86
  • 137
HaseebR7
  • 447
  • 4
  • 11
  • Couldn't resolve proxy sounds like it's just for DNS errors, but you have no DNS name so I wouldn't expected to see it. – Flexo Jan 10 '14 at 19:28
  • You are just setting the proxy option there ... curl won't try to use it until you actually send a request. – Markku K. Jan 10 '14 at 19:29
  • @LulzAge While often seen in forums, it is **not** appropriate on SO to edit the Q and put "SOLVED" in the title. Please don't do that in the future. Instead, pick the correct answer and mark it as "accepted". That way the information can be processed by the site and be handled accordingly. – Daniel Frey Jan 10 '14 at 19:48
  • @DanielFrey Oh,Ok.I'll keep that in mind. – HaseebR7 Jan 10 '14 at 20:04

1 Answers1

0

Thanks for the replies guys.

I looked "CURLE_COULDNT_RESOLVE_PROXY" on google and came across a few examples.

Turns out i had to call curl_easy_perform(curl_handle) after every curl_easy_setopt to get the error codes.

err = curl_easy_perform(curl_handle);
cout << err;
HaseebR7
  • 447
  • 4
  • 11