/** * Gets local host. Implementation will first attempt to get a non-loopback * address. If that fails, then loopback address will be returned. * <p> * Note that this method is synchronized to make sure that local host * initialization happens only once. * * @return Address representing local host. * @throws IOException If attempt to get local host failed. */ public static synchronized InetAddress getLocalHost() throws IOException { if (locHost == null) // Cache it. resetLocalHost(); return locHost; }
/** * Determines whether current local host is different from previously cached. * * @return {@code true} or {@code false} depending on whether or not local host * has changed from the cached value. * @throws IOException If attempt to get local host failed. */ public static synchronized boolean isLocalHostChanged() throws IOException { InetAddress locHost0 = locHost; return locHost0 != null && !resetLocalHost().equals(locHost0); }
/** * Gets local host. Implementation will first attempt to get a non-loopback * address. If that fails, then loopback address will be returned. * <p> * Note that this method is synchronized to make sure that local host * initialization happens only once. * * @return Address representing local host. * @throws IOException If attempt to get local host failed. */ public static synchronized InetAddress getLocalHost() throws IOException { if (locHost == null) // Cache it. resetLocalHost(); return locHost; }
/** * Determines whether current local host is different from previously cached. * * @return {@code true} or {@code false} depending on whether or not local host * has changed from the cached value. * @throws IOException If attempt to get local host failed. */ public static synchronized boolean isLocalHostChanged() throws IOException { InetAddress locHost0 = locHost; return locHost0 != null && !resetLocalHost().equals(locHost0); }