cURL / Mailing Lists / curl-library / Single Mail


CURLINFO_LASTSOCKET and muli-interface

From: Christian Hägele <>
Date: Wed, 4 Jun 2014 16:31:16 +0200


I'm using libcurl (7.36) for many things. One of the purposes is to use
it's capability for platform independent proxy-authentication. (Main
platform is Windows, but also Mac, Android, Linux).
Until now I used libcurl for proxy-authentication via the easy-interface
(using curlpp, but that doesn't matter) and set the CURLOPT_CONNECT_ONLY
option. After the connect was successful I get the connected socket via
CURLINFO_LASTSOCKET and use the socket in my code without any further use
of libcurl.
That worked fine so far.

I tried to change everything to asynchronous and use the muli-interface.
The problem is that CURLINFO_LASTSOCKET on the easy-handle always returns
BAD_SOCKET. I looked in the code and saw that this "feature" is not
supported when using the multi-interface. There is no public function to
retrieve the last used socket from the multi-handle.
I found a workaround so that I remember the lone surviving socket from the
curl_socket_callback. That feels like a hack to me. (BTW: There are 2
sockets opened for some reason. One is closed and never used and the other
one "survives" and luckily it is the socket I'm looking for). I don't know
if that hack will always work...

Is there any other way to achieve what I'm trying to do? Maybe I could
implement a better way to use libcurl to do proxy-authentication and
CONNECT only. Are there already ideas for that? (There is also Known Issue

I'm looking forward for any suggestions on this topic.



List admin:
Received on 2014-06-04