diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 5 | ||||
-rw-r--r-- | cpp/src/Ice/Network.cpp | 23 | ||||
-rw-r--r-- | cpp/src/Ice/Network.h | 1 |
3 files changed, 27 insertions, 2 deletions
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index 5f9034be027..66dc8abb135 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -1316,8 +1316,9 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi _proxyFactory = new ProxyFactory(this); - bool ipv4 = _initData.properties->getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; - bool ipv6 = _initData.properties->getPropertyAsIntWithDefault("Ice.IPv6", 1) > 0; + const bool isIPv6Supported = IceInternal::isIPv6Supported(); + const bool ipv4 = _initData.properties->getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; + const bool ipv6 = _initData.properties->getPropertyAsIntWithDefault("Ice.IPv6", isIPv6Supported ? 1 : 0) > 0; if(!ipv4 && !ipv6) { throw InitializationException(__FILE__, __LINE__, "Both IPV4 and IPv6 support cannot be disabled."); diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index cf8a77defbe..ce28c1bac3f 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -1097,6 +1097,29 @@ IceInternal::compareAddress(const Address& addr1, const Address& addr2) } #ifdef ICE_OS_WINRT +bool +IceInternal::isIPv6Supported() +{ + return true; +} +#else +bool +IceInternal::isIPv6Supported() +{ + SOCKET fd = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP); + if(fd == INVALID_SOCKET) + { + return false; + } + else + { + closeSocketNoThrow(fd); + return true; + } +} +#endif + +#ifdef ICE_OS_WINRT SOCKET IceInternal::createSocket(bool udp, const Address&) { diff --git a/cpp/src/Ice/Network.h b/cpp/src/Ice/Network.h index 179ebab9582..01418b714cb 100644 --- a/cpp/src/Ice/Network.h +++ b/cpp/src/Ice/Network.h @@ -216,6 +216,7 @@ ICE_API ProtocolSupport getProtocolSupport(const Address&); ICE_API Address getAddressForServer(const std::string&, int, ProtocolSupport, bool); ICE_API int compareAddress(const Address&, const Address&); +ICE_API bool isIPv6Supported(); ICE_API SOCKET createSocket(bool, const Address&); ICE_API SOCKET createServerSocket(bool, const Address&, ProtocolSupport); ICE_API void closeSocketNoThrow(SOCKET); |