Please nominate your Qt Champions for 2021!

Why udpsocket does not receive anything?

  • I connect a desktop which has Ubuntu12 installed to a microcontroller board directly by ethernet cable. Microcontoller side does not have any TCP/IP stack and server related function, it can only send out UDP format packet. So when ethernet cable are plugged, desktop computer cannot automatically configured for network. I manually set IP address, submask, gateway, and manually turned it on. with the WireShark's help, I can see the UDP packet coming from microcontrollor and UDP packet sent out by desktop. both side boardcast UDP packet out by setting dest IP to The problem is that the breakpoint I set in the SLOT function processPendingData() for UDP readready signal is never reached, that means my Qt program does not received any UDP packet, although I can see the coming in UDP packet listed in the Wireshark.

    I tried to bind UDP to a special port, but it also does not receive any UDP Packet.

    RemoteContol::RemoteContol(QWidget *parent) :
    ui(new Ui::RemoteContol)

    connect(&udpSocket, SIGNAL(readyRead()), this, SLOT(processPendingData()));


    void RemoteContol::sendSettingParameters(void)
    QByteArray datagram;
    QDataStream out(&datagram,QIODevice::WriteOnly);
    out << "aaabbbccc";

    void RemoteContol::processPendingData(void)
    QByteArray datagram;
    do {
    } while (udpSocket.hasPendingDatagrams());

  • Please use code wrappings as explained "in here.":
    This makes your code sample readable.

  • Just found that if microcontroller side sent data out to Ip,desktop can receive it, but if it broadcast it, desktop cannot receive it. Do not know why yet.

  • Moderators

    ubuntu comes with a firewall. Maybe that is getting into the way?

Log in to reply