gethostbyname() is able to do IPv6 resolutions (eg. ip6-localhost), and is working on IPv4 numeric addresses by returning the address unchanged. However, it doesn't work on IPv6 numeric addresses. In that cases, it returns a NULL pointer, while I think it should return the IPv6 numeric address unchanged.
What exactly doesn't work? The only thing I see not being done is handling IPv6-mapped-IPv4 addresses for AF_INET queries. That's hardly worth the complications, people have to jump through hoops to create such strings.
Please consider the following testcase: #include <netdb.h> #include <stdio.h> int main() { if( gethostbyname( "127.0.0.1" ) == NULL ) printf( "error: %d\n", (int)h_errno ); else printf( "found\n" ); if( gethostbyname( "::1" ) == NULL ) printf( "error: %d\n", (int)h_errno ); else printf( "found\n" ); } Numeric IPv4 addresses are left unchanged. That's not the case for IPv6 addresses.
(In reply to comment #2) > Please consider the following testcase: > [...] That's not worth the extra complexity. This never worked, people hardly ever use mapped addresses, and gethostby* should not *EVER* be used in the first place. Anything to get people away from gethostby* is a good thing.