CURLOPT_IPRESOLVE(3)

okay bestie, welcome to the CURLOPT_IPRESOLVE(3) page from the Library Functions Manual β€” we're talking about picking which IP protocol version to use, and it's honestly iconic πŸ’…

πŸŽ€ NAME πŸŽ€

CURLOPT_IPRESOLVE β€” the IP protocol version to use ✨

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IPRESOLVE, long resolve);

🌸 DESCRIPTION 🌸

This one lets an application choose what kind of IP addresses to use when it's establishing a connection or choosing one from the connection pool. It's super interesting when you're using hostnames that resolve to more than one IP family β€” like, okay, which one are we actually picking? πŸ‘€

quick heads-up: if the URL provided for a transfer contains a numerical IP version as a host name, this option does not override or prohibit libcurl from using that IP version. no cap.

Available values for this option are:

  • CURL_IPRESOLVE_WHATEVER β€” default, can use addresses of all IP versions that your system allows πŸ’–
  • CURL_IPRESOLVE_V4 β€” uses only IPv4 addresses πŸŽ€
  • CURL_IPRESOLVE_V6 β€” uses only IPv6 addresses πŸ¦‹

πŸ’… DEFAULT πŸ’…

CURL_IPRESOLVE_WHATEVER β€” periodt.

🌈 PROTOCOLS 🌈

This functionality affects all supported protocols ⭐

πŸ“ EXAMPLE πŸ“

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");

    /* of all addresses example.com resolves to, only IPv6 ones are used */
    curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);

    result = curl_easy_perform(curl);

    curl_easy_cleanup(curl);
  }
}

🧚 HISTORY 🧚

The CURL_IPRESOLVE_* macros became long types in 8.15.0; before this version a long cast was necessary when passed to curl_easy_setopt(3) ⏳

πŸ‘‘ AVAILABILITY πŸ‘‘

Added in curl 7.10.8 ✨

πŸ”₯ RETURN VALUE πŸ”₯

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK; non-zero means an error occurred β€” see libcurl-errors(3) 😭

πŸ’œ SEE ALSO πŸ’œ


bye bestie 🫢 this page is from libcurl, dated 2026-10-12 β€” and yes, the footer vibe is immaculate πŸ’–

πŸ“¦ where this page comes from