curl-library
Re: SO_REUSEADDR and libcurl
Date: Tue, 1 Jul 2014 08:18:45 +0200
On Mon, Jun 30, 2014 at 09:43:53AM -0400, Sachin Nikumbh wrote:
> Thanks a lot for the response. I am going to investigate the cause behind
> sockets getting into the TIME_WAIT state. But in the mean time, I am trying to
> understand how CURLOPT_SOCKOPTFUNCTION and CURLOPT_OPENSOCKETFUNCTION can be
> used. I could not find any examples so, I am trying to understand their
See docs/examples/externalsocket.c, docs/examples/asiohiper.cpp and
docs/examples/externalsocket.c.
> functionality by following the documentation for these options and just want to
> make sure that my understanding is correct. I was wondering if ou could help me
> with this.
> * given that I need to set the SO_REUSEADDR option after the socket is created,
> I need to use the CURLOPT_SOCKOPTFUNCTION option
That's one way.
> * curlsockettype in this case needs to be CURLSOCKTYPE_IPCXN
If you only want to catch outgoing sockets, yes.
> * the 2nd input to the callback, curl_socket_t is the socket handle which needs
> to be used with setsockopt() function
Yes.
> * I am not sure what the first input, void*, is representing
It holds the pointer passed in from the CURLOPT_SOCKOPTDATA option.
> * How are CURLOPT_SOCKOPTFUNCTION and CURLOPT_OPENSOCKETFUNCTION options
> related? The description of the case when the callback needs to return 2
They are two independent callback functions called at two different times in
the connection process.
> mentions CURLOPT_OPENSOCKETFUNCTION. Does it mean if I am setting
> CURLOPT_SOCKOPTFUNCTION, I also need to set the CURLOPT_OPENSOCKETFUNCTION
> handler as well?
No, they are independent. Returning CURL_SOCKOPT_ALREADY_CONNECTED means that
libcurl won't call connect() on the socket.
>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-07-01