curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: Custom resolve of Address

From: Dan Fandrich via curl-library <>
Date: Mon, 22 Nov 2021 11:54:33 -0800

On Mon, Nov 22, 2021 at 01:26:41PM +0100, Marcel via curl-library wrote:
> I'm in need of a callback, that let me resolve a domain to an IP address.
> I have a modem module which communicates via AT commands with my embedded linux device.
> The only thing currently not working is resolving DNS names.
> There is a way of defining DNS names beforehand (using CURLOPT_RESOLVE), but I don't see a way of using it for dynamic queries, e.g. during or before a connect.

Is the problem that the name doesn't resolve at all or resolves incorrectly? If
the latter, then you should be able to use the CURLOPT_OPENSOCKETFUNCTION and
CURLOPT_SOCKOPTFUNCTION callbacks to substitute the right address by ignoring
the supplied address and opening the socket with the right one. If the former,
I would think you could just extract the host name from the URL using the
curl_url API and populate the DNS cache after resolving the name yourself.
There are a few boundary cases (redirects, certificate revocation checks,
proxies, etc.) with this approach but the simple cases should work fine.

Received on 2021-11-22