Inside an application's existing libcurl initialization and easy-handle lifecycle:

curl_easy_setopt(handle, CURLOPT_URL, "https://example.com/");
curl_easy_setopt(handle, CURLOPT_PROXY, "127.0.0.1:1080");
curl_easy_setopt(handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);
curl_easy_setopt(handle, CURLOPT_NOPROXY, "");
curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, 5L);
curl_easy_setopt(handle, CURLOPT_TIMEOUT, 15L);

CURLPROXY_SOCKS5_HOSTNAME sends the destination hostname along the SOCKS path. CURLPROXY_SOCKS5 instead resolves it on the client, which can use a different network's DNS view. A C++ HTTP client using libcurl does not need its own SOCKS handshake merely to choose this route. For a permitted public endpoint, the SOCKS5 proxy list offers host and port candidates to replace the illustrative loopback listener.

The empty CURLOPT_NOPROXY value makes the proxy test deliberate. Preserve intended bypasses when adapting it to normal application policy. These options affect this handle; other libraries and sockets in the process do not inherit them.

Check option-setting and transfer return values through the application's error handling. Failure to reach or negotiate with SOCKS can precede any HTTP response, so it does not supply a website status code.

Required proxy credentials use the supported proxy authentication settings and secret mechanism, separately from the website's login. Keep TLS verification enabled: opening a connection through SOCKS does not establish the identity of the HTTPS service.

Ũhoro ũhĩtĩte