Ok, sounds good. I will go ahead and implement the ares_set_socket_sockopt_cb functionality.
Attached is a patch file for that simple change, if it is ok I will add the documentation.
Thanks,
Fredrik
________________________________________
From: c-ares-bounces_at_cool.haxx.se [c-ares-bounces_at_cool.haxx.se] on behalf of Lijo Antony [lta_at_one.com]
Sent: Thursday, June 28, 2012 13:24
To: c-ares_at_cool.haxx.se
Subject: Re: socket callbacks
On 06/28/2012 11:53 AM, Fredrik Jansson wrote:
> Hi!
>
> That kind of open/close-socket functions would work great for me.
>
> I cannot see that there is that much work with this approach:
>
> 1. Check if we have opensocket cb otherwise call socket.
>
> The opensocket_cb would have the sams arguments as the "socket" call plus an additional user data ptr.
>
> 2. Replace the sclose macro with a function that checks if we have a closesocket cb.
>
> Or am I over simplifying things?
>
This is correct.
But for a generic use case, a few more aspects may have to be
considered. For example, as Daniel mentioned, if user want to return a
socket which is already connected, there should be a way to inform
c-ares, not to do connect again. Callbacks may also require parameters,
by which c-ares can inform additional details for the socket(ip, port,
protocol etc). I guess Daniel and others would be able to give better
suggestions on this.
> Lijo, would that provide what you (will) need?
My use case would require the c-ares interface be similar to (and
complex) that of libcurl. Specifically, I would require the socket
details in opencallback and a way to avoid connect by c-ares, possibly
using sockopt callback.
I think the best way would be to go ahead with the way you want it.
Additional features can be added later. You may want to take a look at
libcurl interface, as it would help you to have an extensible api.
-lijo