On Nov 28, 2007, at 2:17 PM, Bill Kelly wrote: > So.... On the one hand I'm left wondering why getaddrinfo() > previously used to do reverse lookups, if it's not supposed to. gethostbyname, gethostbyaddr, getaddrinfo, and getnameinfo all work for me as documented on MacOS X via Ruby's Socket class. > But anyway, if the above information is correct, then it seems > Ruby's Socket.gethostbyname should be changed to use getnameinfo() > instead of just getaddrinfo() to perform reverse lookups. gethostbyname/gethostbyaddr are IP specific functions getaddrinfo/getnameinfo are the protocol-agnostic versions for environments where something other than IP is being used to communicate. They are also provide more general interfaces to name/address/port information. The code you showed is a bit odd. If getaddrinfo() returns a result then res->ai_cnonname should point to the hostname but only if the AI_CANONNAME flag was set in the call to getaddrinfo. Try adding: hints.ai_flags = AI_CANONNAME and see if you get something useful back in ai_canonname. If you don't set that hint then all you've done with getaddrinfo() is convert the text version of the IP address to a binary version of the address, which can then be used with getnameinfo to complete the lookup. It looks like Ruby 1.8 sets CANONNAME when it calls getaddrinfo so it is a bit puzzling as to why it isn't working on your system, perhaps a DNS configuration issue?