Question about getaddrinfo in Inet4AddressImpl.c
luchsh at linux.vnet.ibm.com
Tue Oct 25 19:33:21 PDT 2011
On 10/25/2011 05:41 PM, Chris Hegarty wrote:
> On 10/25/11 08:31 AM, Charles Lee wrote:
>> Hi guys,
>> I am reading some native code in the jdk repos. I find that in
>> Inet4AddressImpl.c (folder solaris), gethostbyname is used. Meanwhile in
>> the Inet6AddressImpl.c. getaddrinfo is used. My question is why inet4
>> does not use getaddrinfo? Any concern here?
> The Inet4AddressImpl implementation clearly only needs to deal with
> IPv4 addresses, so gethostbyname is sufficient. Historically, when
> this code was added way back we couldn't be guaranteed that the IPv6
> API's would be available on all platforms.
getaddrinfo is now part of POSIX standard, and gethostbyname was removed
from POSIX specification by POSIX.1-2008. So the suggested change is a
Moreover getaddrinfo supports IPv4 too, so I think it will not bring any
additional dependencies on an platform without IPv6, right?
> We do still support building without IPv6 and I would be reluctant to
> to put a dependency from Inet4AddressImpl on getaddrinfo for this reason.
> If your specific issue is with __GLIBC__, I wonder if it could be
> replaced with __LINUX__?? We'd need to look more into this.
>> There are some pros I can see if getaddrinfo is used in the
>> 1. Code will look more clean and portable :-)
>> 2. __GLIBC__ can be omitted. I have grep the __GLIBC__ in the jdk/src
>> directories, only Inet4AddressImpl use it.
More information about the net-dev