Re: Questions on getaddrinfo



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...
.



Relevant Pages

  • Re: How is DNS resolution working?
    ... > network is really our private corporate network (which in turn is ... > DNS: 192.168.1.10 ... > resolution is being properly handled by the DNS server on Machine B ... > resolves) on the external network ...
    (microsoft.public.win2000.dns)
  • Re: How is DNS resolution working?
    ... > network is really our private corporate network (which in turn is ... > DNS: 192.168.1.10 ... > resolution is being properly handled by the DNS server on Machine B ... > resolves) on the external network ...
    (microsoft.public.win2000.networking)
  • Re: DNS-NetBios name resolution order
    ... it could help with slow access to shares but that depends on whether there is another problem other that the default name resolution ... You could setup a zone on your local DNS server, add A records for the local hosts and then use this DNS server on home LAN. ... You can add forwarders to the DNS server so the clients can resolve names out on the internet. ... >> of XP will attempt to resolve this name using Netbios. ...
    (microsoft.public.windows.server.networking)
  • Re: Cannot join domain by Windows XP Tablet Edition
    ... When I try to join the Windows 2003 Active Directory Domain, ... But I don't know how to check the "name resolution ... Check your DNS server setup ... I guess my DNS server is fine. ...
    (microsoft.public.windowsxp.network_web)
  • Re: Cannot join domain by Windows XP Tablet Edition
    ... When I try to join the Windows 2003 Active Directory Domain, ... But I don't know how to check the "name resolution ... Check your DNS server setup ... I guess my DNS server is fine. ...
    (microsoft.public.windowsxp.network_web)