summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/UdpTransceiver.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp
index 9eee012ff94..3c180e25031 100644
--- a/cpp/src/Ice/UdpTransceiver.cpp
+++ b/cpp/src/Ice/UdpTransceiver.cpp
@@ -353,18 +353,33 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s
if(isMulticast(_addr))
{
setReuseAddress(_fd, true);
- _mcastAddr = _addr;
#ifdef _WIN32
//
// Windows does not allow binding to the mcast address itself
// so we bind to INADDR_ANY (0.0.0.0) instead.
//
+ _mcastAddr = _addr;
getAddressForServer("", getPort(_mcastAddr), _addr,
_mcastAddr.ss_family == AF_INET ? EnableIPv4 : EnableIPv6);
-#endif
+ doBind(_fd, _addr);
+ if(getPort(_mcastAddr) == 0)
+ {
+ int port = getPort(_addr);
+ if(_mcastAddr.ss_family == AF_INET)
+ {
+ reinterpret_cast<sockaddr_in*>(&_mcastAddr)->sin_port = htons(port);
+ }
+ else
+ {
+ reinterpret_cast<sockaddr_in6*>(&_mcastAddr)->sin6_port = htons(port);
+ }
+ }
+#else
doBind(_fd, _addr);
+ _mcastAddr = _addr;
+#endif
setMcastGroup(_fd, _mcastAddr, mcastInterface);
}
else