Split getnameinfo into separate functions for host and service lookups, and for different address families. (cherry picked from commit 2dce81a3) (cherry picked from commit e5bcbfc2)