curl-library
Re: curl_multi_socket_action, epoll and HTTP redirect
Date: Wed, 06 Mar 2013 10:02:46 +0100
Am 05.03.2013, 21:54 Uhr, schrieb Erik Johansson <erik_at_ejohansson.se>:
> My current work-around is to keep track of all sockets added in the
> socket function callback and also listen to CURLOPT_SOCKOPTFUNCTION to
> know when a new socket has been added that wasn't notified in the
> socket callback. This works, but seems a bit hackish.
You should always keep track of all socket. That's not a hack!
> So, have I misunderstood something and it actually works if done right
> or is this an issue in cURL?
There are 2 possible solutions I know of:
1. If the CURLOPT_SOCKOPTFUNCTION is called with a new socket the socketp
(5th parameter in the function) is NULL. Given you set this pointer to
some value (which you should do) you can determine if it is a new socket
you never heard of or it is a socket you should already know.
2. Use the CURLOPT_OPENSOCKETFUNCTION and CURLOPT_CLOSESOCKETFUNCTION. In
that case you will know when libcurl opens or closes a socket. But be
aware that it is possible that the CURLOPT_SOCKOPTFUNCTION might be called
for a socket that was already closed via the CURLOPT_CLOSESOCKETFUNCTION!
I hope that helps.
Regards,
Christian
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-03-06