Nov 6th, 2000, 10:55 PM
How do I obtain the real-time multiple IP addresses for a given machine?
I've used:
InetAddress ip = InetAddress.getLocalHost();//Expect to remain constant
InetAddress mip[] = InetAddress.getAllByName( ip.getHostName() );//Expect to change
When the "multiple IP address array" changes (as when a pc dials an ISP obtaining a dynamically assigned IP) and I call the method again to update mip, I still get the original results. I've found out that there is a caching mechanism in the private method "getAllByName0" which is called by "getAllByName". Perhaps there is a way to flag caching on/off before my call to the public method "getAllByName".
I asked this at http://www.hotdispatch.com/home?aff=75141470 and a reply looked promising:
"Using InetAddressCachePolicy.setIfNotSet InetAddressCachePolicy.FOREVER);
Before you setup SecurityManager.", but I could never find the class "InetAddressCachePolicy" and the person never replied again. I couldn't find the class at java.sun.com either.
I've used:
InetAddress ip = InetAddress.getLocalHost();//Expect to remain constant
InetAddress mip[] = InetAddress.getAllByName( ip.getHostName() );//Expect to change
When the "multiple IP address array" changes (as when a pc dials an ISP obtaining a dynamically assigned IP) and I call the method again to update mip, I still get the original results. I've found out that there is a caching mechanism in the private method "getAllByName0" which is called by "getAllByName". Perhaps there is a way to flag caching on/off before my call to the public method "getAllByName".
I asked this at http://www.hotdispatch.com/home?aff=75141470 and a reply looked promising:
"Using InetAddressCachePolicy.setIfNotSet InetAddressCachePolicy.FOREVER);
Before you setup SecurityManager.", but I could never find the class "InetAddressCachePolicy" and the person never replied again. I couldn't find the class at java.sun.com either.