res_query()

Paul Vixie vixie at sa.vix.com
Thu Aug 4 16:02:29 UTC 2005


appaji arunkumar <arun_appaji at yahoo.co.in> writes:
> 
> Can anybody suggest me if we use res_query() funcion in bind9 will give
> me the Ip address for given domain name. if not suggest me for the same.

Paul Vixie <vixie at sa.vix.com> writes:
> 
> you could do it that way, but there are easier ways, like gethostbyname()
> or getaddrinfo().

in an e-mail'd followup, appaji arunkumar wrote as follows:
> 
> but if i use gethostbyname() i wont be able to use the some of the
> optional parameters like number of reties, retry interval, etc. for DNS
> client setup.
>  
> or is it possible to initialize the these parameters using resolver
> library res_init() and call the function gethostbyname() for IPv6
> address.

gethostbyname() and getaddrinfo() usually use the global resolver context
called "res" but there's no requirement that they do so on every system.
if you are sure that your application will only link against ISC "libbind"
then you can just change res.res_* and use the functions i mentioned earlier.

note that gethostbyname() will only return IPv6 addresses if the option
"RES_USE_INET6" is set.  you can override this behaviour by using
gethostbyname2() instead.

if you want to control your own options and not have to wonder whether
gethostbyname() or gethostbyname2() is going to follow the global "res",
then you should use the thread-safe, poorly documented, "IRS" api.
-- 
Paul Vixie



More information about the bind-users mailing list