GNURLOPT_INTERFACE(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸŽ€ GNURLOPT_INTERFACE(3) πŸŽ€

okay bestie, this is the GNURLOPT_INTERFACE(3) page from the curl_easy_setopt options manual β€” yes, the curl easy setopt options family. we're talking outgoing interfaces, and it's giving network main character energy πŸ’…

🌸 NAME 🌸

CURLOPT_INTERFACE β€” source interface for outgoing traffic ✨

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERFACE, char
       *interface);

πŸ’– DESCRIPTION πŸ’–

okay so you pass a char * as the parameter. This sets the interface name to use as the outgoing network interface. The name can be an interface name, an IP address, or a host name. slay. 🫢

If the parameter starts with "if!" then it is treated as only an interface name, and no attempt will ever be made to treat it as an IP address or to do name resolution on it. If the parameter starts with "host!" it is treated as either an IP address or a hostname. Hostnames are resolved synchronously. Using the if! format is highly recommended when using the multi interfaces to avoid allowing the code to block. If "if!" is specified but the parameter does not match an existing interface, CURLE_INTERFACE_FAILED is returned from the libcurl function used to perform the transfer. 😭

libcurl does not support using network interface names for this option on Windows. not the Windows limitation πŸ’€

The application does not have to keep the string around after setting this option. so you can let the string go after setting it β€” no need to clutch it forever, bestie. πŸŽ€

🌈 DEFAULT 🌈

NULL, use whatever the TCP stack finds suitable. lowkey the TCP stack is the main character here. πŸ‘‘

⭐ PROTOCOLS ⭐

All. every single one, periodt. πŸ’…

πŸ“ EXAMPLE πŸ“

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/foo.bin");

  curl_easy_setopt(curl, CURLOPT_INTERFACE, "eth0");

  ret = curl_easy_perform(curl);

  curl_easy_cleanup(curl);
}

🧚 AVAILABILITY 🧚

The "if!" and "host!" syntax was added in 7.24.0. iykyk. ✨

πŸ”₯ RETURN VALUE πŸ”₯

Returns CURLE_OK on success or CURLE_OUT_OF_MEMORY if there was insufficient heap space. no cap. πŸ’œ

🌸 SEE ALSO 🌸


xoxo, this page is from libcurl 7.37.0, dated 17 Jun 2014 β€” bye bestie, go route that traffic with main character energy πŸ’–πŸ¦‹

πŸ“¦ where this page comes from