InetAddress: UnknownHostException bug?
Urban Widmark
urban@svenskatest.se
Tue Apr 13 13:22:00 GMT 1999
Hello again,
I have a problem with name lookups in InetAddress, and this one I don't
think I can solve myself.
Linux 2.2.5, glibc 2.0.7 (rpm says: glibc-2.0.7-19)
For all names not in my local /etc/hosts file I get an
UnknownHostException, even though the lookup seems to have returned
something useful. The following fails:
InetAddress ia;
ia = InetAddress.getByName("www.svenskatest.se");
System.err.println("ia: " + ia);
Adding some debug printouts to natInetAddress.cc
(line ~122, GETHOSTBYNAME_R_RETURNS_INT is defined)
fprintf(stderr, "%s %d\n", hostname, ok);
fprintf(stderr, "h_name: %s\n", hent_r.h_name);
fprintf(stderr, "h_aliases[0]: %s\n", hent_r.h_aliases[0]);
fprintf(stderr, "h_aliases[1]: %s\n", hent_r.h_aliases[1]);
fprintf(stderr, "h_addr_list[0]: %08x\n", hent_r.h_addr_list[0]);
fprintf(stderr, "h_addr_list[1]: %08x\n", hent_r.h_addr_list[1]);
fprintf(stderr, "hptr: %08x\n", hptr);
gives the following output:
www.svenskatest.se 0
h_name: (null)
h_aliases[0]: svtest
h_aliases[1]: (null)
h_addr_list[0]: bffff638
h_addr_list[1]: 00000000
hptr: 00000000
java.net.UnknownHostException: www.svenskatest.se
The real name of the machine is svtest.eisi.se, which is probably where it
got the svtest part from. It also shows that it did get an answer from
the dns.
Manually undefining GETHOSTBYNAME_R (forcing gethostbyname) makes the
lookups work.
Something known with gethostbyname_r and glibc 2.0.7 ?
/Urban
---
Urban Widmark urban@svenskatest.se
Svenska Test AB +46 90 71 71 23
More information about the Java
mailing list