Question about getaddrinfo in Inet4AddressImpl.c
Charles Lee
littlee at linux.vnet.ibm.com
Wed Oct 26 00:47:19 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.
>
> 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.
>
> -Chris.
>
>>
>> There are some pros I can see if getaddrinfo is used in the
>> Inet4AddressImpl:
>> 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.
>>
>
Hi Chris,
I have check the code a little bit to find that getaddrinfo_ptr is also
loaded in the ifdef AF_INET6 block on solaris and linux. But I do not
get getaddrinfo is ipv6 specified. Do I miss sth?
--
Yours Charles
More information about the net-dev
mailing list