cURL / Mailing Lists / curl-library / Single Mail


Re: [PATH] check ip callback

From: Alexey Pesternikov <>
Date: Thu, 13 Sep 2007 10:33:19 -0700

On 9/12/07, Dan Fandrich <> wrote:
> It would be useful if such a callback could also be used to replace the IP
> address to be used for the connection as well. That's a feature that
> is requested regularly on this list.

No problem.

What about extending the existing curl_sockopt_callback callback function
> instead of creating a new one? An additional address parameter could be
> tacked on to the end of the parameter list in a backward-compatible way.
> That would provide the address that is about to be used in the subsequent
> connect call, and could also permit it to be changed.

It could be useful to have the ability at least to change a protocol family
(domain), and that means the translation (connect.c:691) should be done
before socket opening (connect.c:675) or library should detect the address
change and reopen socket (and call curl_sockopt_callback again?).
One more thing: we probably need to make Curl_addrinfo public (but
Curl_addrinfo depends on config CURLRES_IPV6 -> ENABLE_IPV6) or have some
more parameters like that:
typedef int (*curl_sockopt_callback)(void *clientp,
                                     curl_socket_t curlfd,
                                     curlsocktype purpose,
                                     int* ai_family,
                                     int* ai_socktype,
                                     int* ai_protocol,
                                     struct sockaddr *ai_addr

If you guys ok with that I'm going to implement that and produce a patch.
Received on 2007-09-13