Skip to content

CURLINFO_LOCAL_IP and CURLINFO_LOCAL_PORT do not work on reused connections. #7660

Closed
@maxdymond

Description

@maxdymond

I did this

$ cat demo.c
#include <stdio.h>
#include <curl/curl.h>

int main()
{
  CURL *curl;
  curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
    curl_easy_perform(curl);
    curl_easy_perform(curl);

    {
      char *ip;
      long port;
      curl_easy_getinfo(curl, CURLINFO_LOCAL_IP, &ip);
      curl_easy_getinfo(curl, CURLINFO_LOCAL_PORT, &port);
      printf("We used local IP and port: %s : %ld\n", ip, port);
    }
    curl_easy_cleanup(curl);
  }
  return 0;
}

I expected the following

<website contents>
We used local IP and port: 172.19.45.229 : 43382

(I get this with my system library at 7.68)

What I actually get is:

<website contents>
We used local IP and port:  : -1

curl/libcurl version

master

operating system

Linux 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions