[Interest] MultiCast problem. QAbstractSocket::ShareAddress no effect?

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Tue Sep 10 08:20:15 CEST 2013


On Tue, Sep 10, 2013 at 2:03 AM, Guido Seifert <wargand at gmx.de> wrote:

>
> Hi, I worked a little bit more on my problem. Is it possible, that
> QAbstractSocket::ShareAddress has not effect on Qt 5.1.1/64bit/linux?
>
>
The BindFlags you're passing seem to be aimed at making listening to
existing host:port combos (if any) work on both Windows and Linux.
ShareAddress maps to the SO_REUSEADDR socket option. So it should work on
Linux 64-bit.


> I cannot get UPnP messages from my xbmc, when it runs on the same machine.
> With Qt4 this was not a problem. What I did now: I took the
> multicastreceiver from the examples. Only code I changed in it was the IP
> and the port: 239.255.255.250 and 1900. UPnP multicast.
>
> Now I checked with wireshark. When the multicastreceiver was not running,
> I was able to see the UPnP multicast messages, which were sent by the xbmc.
> When the multicastreceiver was running, no xbmc multicastmessages were
> visible in wireshark or in the multicastreceiver.
>
> UPnP multicast messages from other machines were received.
>
> Also when I start a second multicastreceiver, I get:
>


> QNativeSocketEngine::joinMulticastGroup() was not called in
> QAbstractSocket::BoundState
>

In the example that you showed (in your previous mail), did bind() return
true? The docs state that the the socket must be in 'BoundState' for
joinMulticastGroup() to work (otherwise it returns false). Maybe you can
check what bind and joinMulticastGroup return when it's not working.

HTH,
-mandeep


>
> I don't think this should happen, when I connect the first one with
> QAbstractSocket::ShareAddress
>
> Guido
>
>
> > Hi,
> > I currently port a Qt4 program to Qt5. I have the following trouble with
> a multicast socket.
> >
> > On Qt4:
> >
> > mReceiver = new QUdpSocket(this);
> > mReceiver->bind(1900,
> QUdpSocket::ReuseAddressHint|QUdpSocket::ShareAddress);
> > mReceiver->joinMulticastGroup("Address");
> >
> > Works great.
> >
> > Now under Qt5:
> > First I got a warning:
> > QAbstractSocket: cannot bind to QHostAddress::Any (or an IPv6 address)
> ... yada yada
> >
> > Ok, so I changed the code:
> >
> > mReceiver->bind(QHostAddress(QHostAddress::AnyIPv4),1900,
> > QUdpSocket::ReuseAddressHint|QUdpSocket::ShareAddress);
> > mReceiver->joinMulticastGroup("Address");
> >
> > Result? No warning. But I don't receive anything on this port either.
> >
> > Help?
> >
> > Guido
> >
> > _______________________________________________
> > Interest mailing list
> > Interest at qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/interest
> >
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130910/4d33fe04/attachment.html>


More information about the Interest mailing list