curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: Retrieving the local address between connect() and HTTP

From: Jean-Francois Dockes via curl-library <curl-library_at_cool.haxx.se>
Date: Mon, 27 Apr 2020 07:44:15 +0200

Patrick Monnerat via curl-library writes:
> On 4/26/2020 4:44 PM, Jean-Francois Dockes wrote:
> >> Thanks for the CURLOPT_CONNECT_ONLY pointer.
> >>
> >> Is there something to prevent me from using the resulting socket fd with
> >> CURLOPT_OPENSOCKETFUNCTION / CURLOPT_SOCKOPTFUNCTION ? I see that
> >> this is a
> >> bit convoluted, but it gains me the use of the libcurl URL parsing and
> >> connect code instead of DIY. Does it make sense ? Performance is no big
> >> issue in my use case.
>
> Since you are not sensible on performance, I wrote a working example
> that does the job in 2 phases: 1 for the connect and 2 for the HTTP
> protocol, reusing the socket descriptor from 1. It is then possible to
> get the local address between the 2 phases. As it uses
> CURLOPT_CONNECT_ONLY, connection reuse does not apply.
>
> Please find it in attachment.

As mentionned in answer to Ray Satiro, this is largely what I had in mind.

You know how it is when you think of a problem at night and wake up ready
to write the code ? Well, it's even better when you wake up to code already
written :)

Thank you so much !

Cheers,

J.F. Dockes
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-04-27