GNURLOPT_LOCALPORT(3)
π GNURLOPT_LOCALPORT(3) π
okay so this is the GNURLOPT_LOCALPORT(3) page from the curl_easy_setopt options manual, and itβs all about setting the local port number for a socket. Bestie, letβs get into it π
β¨ NAME β¨
CURLOPT_LOCALPORT β set local port number to use for socket. Thatβs the whole name vibe check, periodt π
π¦ SYNOPSIS π¦
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_LOCALPORT, long port);
π DESCRIPTION π
Okay so: pass a long, bestie. This sets the local port number of the socket used for the connection. Itβs giving βpick your own local portβ energy β¨
This can be used in combination with CURLOPT_INTERFACE(3), and you are recommended to use CURLOPT_LOCALPORTRANGE(3) as well when this option is set. Lowkey important, so donβt skip that rec π
Valid port numbers are 1 - 65535. Thatβs the range, no cap. Stay inside it, bestie π
π DEFAULT π
0, disabled - use whatever the system thinks is fine. So if you donβt set it, the system gets main character energy and chooses, fr fr πβοΈ
π PROTOCOLS π
All β literally every protocol, no exceptions. Slay π
π EXAMPLE π
Hereβs the example exactly as the manual gives it, untouched and iconic β and yes, it ate:
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/foo.bin");
curl_easy_setopt(curl, CURLOPT_LOCALPORT, 49152L);
/* and try 20 more ports following that */
curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, 20L);
ret = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
The way that comment is doing the most, and honestly? Weβre obsessed π«Ά
β AVAILABILITY β
Added in 7.15.2. Yes queen, sheβs been around π«
π₯ RETURN VALUE π₯
Returns CURLE_OK. Thatβs it, thatβs the return value tea β
π SEE ALSO π
Those are your besties for this one β go read them if you want the full lore, iykyk π
Bye bestie π«Ά β this was GNURLOPT_LOCALPORT(3) from libcurl 7.37.0, dated 19 Jun 2014. Stay slay π
β¨
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms