Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt 4.8->Network->QUdpSocket->Multicast->joinMulticastGroup() problem
Forum Updated to NodeBB v4.3 + New Features

Qt 4.8->Network->QUdpSocket->Multicast->joinMulticastGroup() problem

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 10.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MedEx
    wrote on last edited by
    #1

    Hi all!
    I'm got a problem with QUdpSocket->Multicast->joinMulticastGroup().
    code
    @QUdpSocket * udpSocketR=new QUdpSocket(this);

    if(!udpSocketR->bind(MPort,QUdpSocket::ShareAddress))
    QMessageBox::warning(this, "warning","bind Receiver - dont worked");
    
    if(udpSocketR->state()!=QAbstractSocket::BoundState)
    QMessageBox::warning(this, "warning","bound Receiver - dont worked");
    
    if(!udpSocketR->joinMulticastGroup(groupAddress,List.at(Index))) //List - QNetworkInterface list,Index -current iface
    QMessageBox::warning(this, "warning","join Receiver - dont worked");
    

    //on this place error -> joinMulticastGroup() = false! (udpSocketR->state()=QAbstractSocket::BoundState)

    if(!connect(udpSocketR, SIGNAL(readyRead()),this, SLOT(processPendingDatagrams())))
    QMessageBox::warning(this, "warning","connect Receiver - dont worked");@
    

    I need your help! OS - fedora 12

    code from example multicast receive
    @groupAddress = QHostAddress("239.255.43.21");

     statusLabel = new QLabel(tr("Listening for multicasted messages"));
     quitButton = new QPushButton(tr("&Quit"));
    
     udpSocket = new QUdpSocket(this);
     udpSocket->bind(45454, QUdpSocket::ShareAddress);    
    
     if(!udpSocket->joinMulticastGroup(groupAddress))   //worked!!! No error!
         qDebug("Not join group");
    
     connect(udpSocket, SIGNAL(readyRead()),
             this, SLOT(processPendingDatagrams()));
     connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
    
     QHBoxLayout *buttonLayout = new QHBoxLayout;
     buttonLayout->addStretch(1);
     buttonLayout->addWidget(quitButton);
     buttonLayout->addStretch(1);
    
     QVBoxLayout *mainLayout = new QVBoxLayout;
     mainLayout->addWidget(statusLabel);
     mainLayout->addLayout(buttonLayout);
     setLayout(mainLayout);
    
     setWindowTitle(tr("Multicast Receiver"));
    

    }

    void Receiver::processPendingDatagrams() //no packets receive!
    {
    while (udpSocket->hasPendingDatagrams()) {
    QByteArray datagram;
    datagram.resize(udpSocket->pendingDatagramSize());
    udpSocket->readDatagram(datagram.data(), datagram.size());
    statusLabel->setText(tr("Received datagram: "%1"")
    .arg(datagram.data()));
    }
    }@
    The packets was sending, but not received to slot processPendingDatagrams()

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mjr_slim
      wrote on last edited by
      #2

      Hi,

      I have had this problem before. It turned out to be the firewall on my fedora system. If your system is not publicly available try the following command on the shell as root

      /etc/rc.d/init.d/iptables stop

      and then try the example multicastsender and multicastreceiver examples that came with Qt. I tried it a moment ago on my laptop and it worked. Currently, I am running Fedora 15 with SE-Linux disabled.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ricox
        wrote on last edited by
        #3

        See at this,
        "Here my post...":http://qt-project.org/forums/viewthread/33573
        I have the same problem but I can't find a way to solve?!?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved