Important: Please read the Qt Code of Conduct -

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

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

    QMessageBox::warning(this, "warning","bind Receiver - dont worked");
    QMessageBox::warning(this, "warning","bound Receiver - dont worked");
    if(!udpSocketR->joinMulticastGroup(groupAddress, //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("");

     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;
     QVBoxLayout *mainLayout = new QVBoxLayout;
     setWindowTitle(tr("Multicast Receiver"));


    void Receiver::processPendingDatagrams() //no packets receive!
    while (udpSocket->hasPendingDatagrams()) {
    QByteArray datagram;
    udpSocket->readDatagram(, datagram.size());
    statusLabel->setText(tr("Received datagram: "%1"")
    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...":
    I have the same problem but I can't find a way to solve?!?

Log in to reply