QUdpSocket not sending

  • Hi All.

    I have setup a QUdpSocket that can receive packets from my device. Now I want to send data TO my device. The device I am sending to is not a PC, right now it will get just about anything coming to the ethernet cable. It is connected directly to my PC with no router in between.

    Here are my observations

    1. Using Wireshark. I can see that I am sending packets everytime.

    2. I can also see that when the computers sends LLMNR protocol packets, my device is receiving it. So the device is still listening.

    3. If I send my packets when I connect my device.. the device gets the packet and act according to the message. However, if I wait 10 seconds after plugging the ethernet cable, it won't work.

    Any help would be appreciated.

  • I forgot to post my code. here it is

    @groupAddress = QHostAddress(""); //QHostAddress::Broadcast);
    udpSocket = new QUdpSocket(this);
    udpSocket->bind(QHostAddress::AnyIPv4, 8200, QUdpSocket::ShareAddress);

    int v = -1;
    if (setsockopt(udpSocket->socketDescriptor(), SOL_SOCKET,
                        SO_RCVBUF, (char *)&v, sizeof(v)) == -1) {

    //fucntion called when sending datagram
    @void UpdFrameBuild::sendDatagram(const QByteArray* datagram){

    if(udpSocket->writeDatagram(datagram->data(), datagram->size(),
                                QHostAddress::Broadcast, 8200)==-1){
        int test = 1;
    //qDebug()<<"Worker:: get called from?: "<<QThread::currentThreadId();


  • Have you checked for errors, I believe it should be in udpSocket->errorString().

  • Good idea.

    I get "Unknown error".. that is all! Not a very helpful message!

Log in to reply

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