The simple code belows fails on Windows with QT5.2 when another process is already bound on the specified port. The ShareAddress flag should allow binding multiple times however. On MacOSX it works fine.
if (false == bind(QHostAddress::AnyIPv4, port_, QUdpSocket::ShareAddress))
{
qDebug() << "Warn: cannot bind to the multicast port " << port_;
qDebug() << error();
}
joinMulticastGroup(QHostAddress(address_));
Is it a bug in QT ? If so is there a workaround ?
Thanks.
As stated in the documentation,
ShareAddress
is ignored on Windows platform.I never test this solution, but in my understanding, you can try to use
QUdpSocket::ReuseAddressHint
as alternative flags for Windows.