summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/Network.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2007-05-16 19:13:34 +0000
committerDwayne Boone <dwayne@zeroc.com>2007-05-16 19:13:34 +0000
commitd87f468730fd906d062e982bc401e450649d5576 (patch)
tree3a3c46780a818eeaa1ed3bea63593121ed9337c2 /cpp/src/Ice/Network.cpp
parentBug 1625 - unused property warning (diff)
downloadice-d87f468730fd906d062e982bc401e450649d5576.tar.bz2
ice-d87f468730fd906d062e982bc401e450649d5576.tar.xz
ice-d87f468730fd906d062e982bc401e450649d5576.zip
Bug 1996 - multihomed hostnames
Diffstat (limited to 'cpp/src/Ice/Network.cpp')
-rw-r--r--cpp/src/Ice/Network.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp
index 33bfec5739f..6e907c4bdbe 100644
--- a/cpp/src/Ice/Network.cpp
+++ b/cpp/src/Ice/Network.cpp
@@ -1260,6 +1260,38 @@ IceInternal::addrToString(const struct sockaddr_in& addr)
}
vector<string>
+IceInternal::getHosts(const string& host)
+{
+ vector<string> result;
+ struct hostent* he = 0;
+ int retry = 5;
+
+ do
+ {
+ he = gethostbyname(host.c_str());
+ }
+ while(he == 0 && h_errno == TRY_AGAIN && --retry >= 0);
+
+ if(he == 0)
+ {
+ DNSException ex(__FILE__, __LINE__);
+ ex.error = h_errno;
+ ex.host = host;
+ throw ex;
+ }
+
+ char** ptr = he->h_addr_list;
+ while(*ptr)
+ {
+ struct in_addr* addr = reinterpret_cast<in_addr*>(*ptr);
+ result.push_back(inet_ntoa(*addr));
+ ptr++;
+ }
+
+ return result;
+}
+
+vector<string>
IceInternal::getLocalHosts()
{
vector<string> result;