Results 1 to 4 of 4

Thread: Can use Udp Multicast Receiver in child-window?

  1. #1
    Join Date
    Jul 2006
    Posts
    42
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Can use Udp Multicast Receiver in child-window?

    Does any one know how to get data from Udp Multicast Receiver in the Mdi child window?

    I am using the Qt5.2.1 in Centos6.5 machine. Currently, if I place the QUdpSocket in the main window, the slot "processPendingDatagram" could be triggered when the readReady signal is emitted. But, if I put the QUdpSocket in the child-window and tried to program a MDI applications, the QUdpSocket can not trigger the child-window.

    My child-window is a QWidget window.
    The codes are in child-window's default constructor:
    QUdpSocket *udpSocket = new QUdpSocket;
    udpSocket->bind(...);
    udpSocket-> jointMulticastGroup(...);
    connect(udpSocket, SIGNAL((readyRead()), this, SLOT(processPendingDatagrams()));

    When I open the child-window, I could see the UpdSocket opend correctly. I knew the data is there, but never got into "processPendingDatagram".

    I would like to know how I could fix this problem?

    Thanks in advanced!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Can use Udp Multicast Receiver in child-window?

    The socket doesn't care where you put it, it knows nothing of any widgets. If your code doesn't work then the problem is elsewhere.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2006
    Posts
    42
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Can use Udp Multicast Receiver in child-window?

    Can anyone tell me how to solve my new problem using QUdpSocket:
    Here are the code:

    QUdpSocket *udpSocket = new QUdpSocket;
    QHostAddress groupAddress = QHostAddress("225.0.0.1");
    udpSocket->bind(QHostAddress::AnyIPv4, 45454, QUdpHost::ShareAddress);
    udpSocket-> jointMulticastGroup(groupAddress);

    connect(udpSocket, SIGNAL(readReady()), this, SLOT(processPendingDatagrams());

    ...

    in processPendingDatagram()
    {
    QByteArray ba;
    ba.resize(udpSocket->pendDatagramSize());
    QHostAddress sender;
    quint16 sendPort;
    udpSocket->readDatagram(ba.data, ba.size(), &sender, &senderPort);

    ...

    I found that I am not only get data from 225.0.0.1, but also get data from 225.0.0.2. Can anyone tell me why and how to eliminate the other IPs?

    Thansk

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Can use Udp Multicast Receiver in child-window?

    Since UDP is connectionless, I think anyone can send you datagrams. You have to filter out the ones you don't want on your own.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 5
    Last Post: 17th September 2013, 06:45
  2. resizing child window with parent window
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 3
    Last Post: 8th May 2012, 19:02
  3. how to drag the child window out of the main window?
    By weixj2003ld in forum Qt Programming
    Replies: 1
    Last Post: 2nd April 2012, 14:09
  4. How to close parent window from child window?
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 14th October 2008, 11:40
  5. Replies: 11
    Last Post: 4th June 2008, 07:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.