diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2007-05-16 19:13:34 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2007-05-16 19:13:34 +0000 |
commit | d87f468730fd906d062e982bc401e450649d5576 (patch) | |
tree | 3a3c46780a818eeaa1ed3bea63593121ed9337c2 /java/src/IceInternal/Network.java | |
parent | Bug 1625 - unused property warning (diff) | |
download | ice-d87f468730fd906d062e982bc401e450649d5576.tar.bz2 ice-d87f468730fd906d062e982bc401e450649d5576.tar.xz ice-d87f468730fd906d062e982bc401e450649d5576.zip |
Bug 1996 - multihomed hostnames
Diffstat (limited to 'java/src/IceInternal/Network.java')
-rw-r--r-- | java/src/IceInternal/Network.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/java/src/IceInternal/Network.java b/java/src/IceInternal/Network.java index 92a1547d234..cfa52fa0e4c 100644 --- a/java/src/IceInternal/Network.java +++ b/java/src/IceInternal/Network.java @@ -654,6 +654,41 @@ public final class Network } public static java.util.ArrayList + getHosts(String host) + { + java.util.ArrayList hosts = new java.util.ArrayList(); + try + { + java.net.InetAddress[] addrs = java.net.InetAddress.getAllByName(host); + for(int i = 0; i < addrs.length; ++i) + { + if(addrs[i] instanceof java.net.Inet4Address) + { + hosts.add(addrs[i].getHostAddress()); + } + } + } + catch(java.net.UnknownHostException ex) + { + Ice.DNSException e = new Ice.DNSException(); + e.host = host; + throw e; + } + + // + // No Inet4Address available. + // + if(hosts.size() == 0) + { + Ice.DNSException e = new Ice.DNSException(); + e.host = host; + throw e; + } + + return hosts; + } + + public static java.util.ArrayList getLocalHosts() { java.util.ArrayList hosts = new java.util.ArrayList(); |