Re: Questions on getaddrinfo
- From: Rick Jones <rick.jones2@xxxxxx>
- Date: Mon, 01 May 2006 23:22:09 GMT
ravin_chauhan@xxxxxxxxxxx wrote:
Thanks for the response. Setting AI_CANONNAME bit does not make any
difference. We have it set in our test app, but lost it in cut paste
when pasting the code.
Tsk, tsk :) If you leave things like that out, how are the people
reading your post supposed to know?-)
Does this query always use the /etc/hosts file. We would like this
to go against DNS. Also, we always get only one addr_info struct
back. We were expecting one for each aliases to that particular
host
I would suggest going deeper into the manpage for getaddrinfo. The
HP-UX 11.11 one at least discusses items such as this:
Name Service Switch-Based Operation
The getnameinfo() and getaddrinfo() library routines internally
call the name service switch to access the ipnodes database
lookup policy configured in the /etc/nsswitch.conf file (see
nsswitch.conf(4)) for the name/address resolution, and services
database lookup policy for the service/port resolution. The
lookup policy defines the order and criteria of the supported
name services that can be used for resolution. If addresses are
not gathered after contacting all the ipnodes directives, and if
the caller has set the ai_family to AF_INET or set ai_flags to
AI_V4MAPPED with an ai_family of AF_INET6,
getaddrinfo()/getnameinfo() uses the hosts directive in the
/etc/nsswitch.conf file to resolve the hostname/address. In
this case, when the hosts directive hostname/address resolution
fails, the error number returned will be that of the error
returned by the hosts directive lookup.
The one on my Linux system does not seem to discuss the matter
directly, but it does have:
FILES
/etc/hosts
/etc/nsswitch.conf
/etc/resolv.conf
and
SEE ALSO
getaddrinfo(3), gethostbyaddr(3), getservbyname(3), getservbyport(3),
inet_ntop(3), socket(3), hosts(5), services(5), hostname(7), named(8)
It is often a very good idea to follow the references in a manpage.
And you can always take a system call trace of your application. That
will, for example, show you if it is opening any files like those
listed above, or creating a socket and sending queries to a DNS server
on port 53.
So, in answer to your question - "It depends." :) If you want to
_always_ go against DNS, no matter how the system has its
nsswitch.conf file setup, I suspect you _may_ need to look for
/etc/resolv.conf and build, send your own DNS queries to the
nameservers therein and parse the responses.
rick jones
--
The glass is neither half-empty nor half-full. The glass has a leak.
The real question is "Can it be patched?"
these opinions are mine, all mine; HP might not want them anyway... :)
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
.
- References:
- Questions on getaddrinfo
- From: ravin_chauhan
- Re: Questions on getaddrinfo
- From: Rick Jones
- Re: Questions on getaddrinfo
- From: ravin_chauhan
- Questions on getaddrinfo
- Prev by Date: Re: Questions on getaddrinfo
- Next by Date: Re: string question
- Previous by thread: Re: Questions on getaddrinfo
- Next by thread: Re: string question
- Index(es):
Relevant Pages
|