site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com -- Marc Majka On 27 Jul, 2005, at 02:38, Mike Richmond wrote: Mike Richmond Global Graphics Software Ltd _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/majka%40apple.com This email sent to majka@apple.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... Determining the name of a host is actually pretty tricky, since there are many different names floating around. There are different names that can be set locally. Network name services (like DNS) may have different ideas of the name. If you are mapping addresses to names, different addresses can map to different names. The best API to use is actually gethostname(). It does a lot of smart things, including caching the name once it's found, and it will be consistent with other software that uses gethostname(), so at least you can think of it as a canonical name. If you really can't use gethostname() and want to iterate through all the network interfaces and look for names associated with them, beware that it will cause a flurry of network activity, and that it may take a long time. We've seen a lot of problems with long DNS query times due to old DNS servers simply dropping some queries on the floor. We saw this with AAAA queries in Panther, although it's a lot better now that we run two threads to do A and AAAA queries in parallel. The same thing happens to some people for PTR queries for 192.168.x.x or 10.x.x.x (and possibly other) addresses that are never answered. The result is a long (30 second) DNS timeout. The actual implementations of getaddrinfo() and getnameinfo() are in Libinfo/lookup.subproj, but they just call lookupd (see netinfo/ servers/lookupd/LUServer.m), which does all the heavy lifting. Finally, about NI_NOFQDN: It's a bug in the LUServer.m code. It isn't stripping off the trailing domain names as it should. I am trying to get an unqualified name for the local host. To do this I loop over the addresses returned by getifaddrs(), select the first AF_INET, running, non-loopback address and call getnameinfo() with the NI_NAMEREQD and NI_NOFQDN flag set. I'm expecting the host name returned by getnameinfo() to be unqualified, but I am getting a fully qualified name as if NI_NOFQDN had not been set. I see this on 10.3.9 and 10.4.2. I've looked at the source at <http://www.opensource.apple.com/ darwinsource/10.4.2/bind9-11/bind9/lib/lwres/getnameinfo.c> and that does take notice of the NI_NOFQDN flag. Am I looking at the right code? Am I mis-understanding what the NI_NOFQDN flag does? This email sent to site_archiver@lists.apple.com