NetworkInterface doesn't see new InetAddress after they've been updated
Sat May 3 22:07:00 GMT 2003
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
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.
More information about the Java