Re: Major problem with hostname resolution in Win2K
On Oct 5, 3:24 am, "Andrew Thompson" <u32984@uwe> wrote:
chrisrocke...@gmail.com wrote:
..
I'm having a terrifically difficult time ...
... I think it's a Win2K problem, but I'm not sure.
Testing beats suspicion 9 times out of ten*.
So keeping that in mind arrange these..
NetworkInterface.getNetworkInterfaces
NetworkInterface.getInetAddresses
InetAddresses.getCanonical name.
.into an SSCCE** and I will provide some test
results for this Win XP Pro box.
Of course, you are right. Here is the code:
import java.net.*;
import java.util.*;
public class GetPublicHostName {
public static void main (String args[]) throws Throwable{
System.out.println("abc");
NetworkInterface iface = null;
for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces();
ifaces.hasMoreElements();){
System.out.println("efg");
iface = (NetworkInterface)ifaces.nextElement();
System.out.println("xInterface:" + iface.getDisplayName());
InetAddress ia = null;
for (Enumeration ips = iface.getInetAddresses();
ips.hasMoreElements();){
ia = (InetAddress)ips.nextElement();
System.out.println(ia.getCanonicalHostName() + " " +
ia.getHostAddress());
}
}
}
}
* ..and 83.7% of statistics are invented on the spot.
** <http://www.physci.org/codes/sscce.html>
--
Andrew Thompsonhttp://www.athompson.info/andrew/
Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200710/1