diff options
Diffstat (limited to 'cpp/src/Ice/Network.cpp')
-rw-r--r-- | cpp/src/Ice/Network.cpp | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index b2d7aeed845..949cbd23be4 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -854,94 +854,6 @@ IceInternal::getAddress(const string& host, int port, struct sockaddr_in& addr) } } -string -IceInternal::getLocalHost(bool numeric) -{ - char host[1024 + 1]; - if(gethostname(host, 1024) == SOCKET_ERROR) - { - SyscallException ex(__FILE__, __LINE__); - ex.error = getSystemErrno(); - throw ex; - } - -#ifdef _WIN32 - - // - // Windows XP has getaddrinfo(), but we don't want to require XP to run Ice. - // - - // - // gethostbyname() is thread safe on Windows, with a separate hostent per thread - // - struct hostent* entry; - int retry = 5; - do - { - entry = gethostbyname(host); - } - while(entry == 0 && WSAGetLastError() == WSATRY_AGAIN && --retry >= 0); - - if(entry == 0) - { - DNSException ex(__FILE__, __LINE__); - ex.error = WSAGetLastError(); - ex.host = host; - throw ex; - } - - if(numeric) - { - struct sockaddr_in addr; - memset(&addr, 0, sizeof(struct sockaddr_in)); - memcpy(&addr.sin_addr, entry->h_addr, entry->h_length); - return inetAddrToString(addr.sin_addr); - } - else - { - return string(entry->h_name); - } - -#else - - struct addrinfo* info = 0; - int retry = 5; - - struct addrinfo hints = { 0 }; - hints.ai_family = PF_INET; - - int rs = 0; - do - { - rs = getaddrinfo(host, 0, &hints, &info); - } - while(info == 0 && rs == EAI_AGAIN && --retry >= 0); - - if(rs != 0) - { - DNSException ex(__FILE__, __LINE__); - ex.error = rs; - ex.host = host; - throw ex; - } - - string result; - if(numeric) - { - assert(info->ai_family == PF_INET); - struct sockaddr_in* sin = reinterpret_cast<sockaddr_in*>(info->ai_addr); - result = inetAddrToString(sin->sin_addr); - } - else - { - result = info->ai_canonname; - } - freeaddrinfo(info); - return result; - -#endif -} - bool IceInternal::compareAddress(const struct sockaddr_in& addr1, const struct sockaddr_in& addr2) { |