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



  • 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()



  • 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.



  • 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?!?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.