This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
NetworkInterface doesn't see new InetAddress after they've been updated
- From: "Scott Gilbertson" <scottg at mantatest dot com>
- To: <java at gcc dot gnu dot org>
- Date: Fri, 2 May 2003 18:14:13 -0400
- Subject: NetworkInterface doesn't see new InetAddress after they've been updated
I'm writing a network setup thing in my embedded application. It lets the
user set IP address, netmask, gateway, dns and dhcp settings, then execs a
script to incorporate the changed configuration files (very
platform-specific, but I can live with that). I wanted to display the
actual IP address on-screen, which is particularly important when using
DHCP.
I tried java.net.NetworkInterface.getByName() and getInetAddresses(), only
to discover that the interfaces and addresses are cached (at least in the
posix case), and therefore don't reflect the changes the user has made
(possibly by enabling DHCP).
Looking at the J2SDK 1.4.0 Javadoc, I don't see any indication of whether
the caching is as-specified for this API. In my case, I'd be happier if it
got a fresh set of IP addresses each time it was called. There would
obviously be some garbage generated in the process, but I suspect these
functions are called rarely in actual use, and of course an application
could cache the IP addresses itself if it wanted to.
Does anyone have an opinion on whether the caching is appropriate and/or
necessary? If not, I'd like to get rid of it.