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: Patrick Monnerat via curl-library <curl-library_at_cool.haxx.se>
Date: Mon, 27 Apr 2020 04:41:27 +0200

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.

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html

Received on 2020-04-27