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. QUdpSocket not sending

QUdpSocket not sending

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.9k 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.
  • B Offline
    B Offline
    bareil76
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bareil76
      wrote on last edited by
      #2

      I forgot to post my code. here it is

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

      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;
      }else{
          udpSocket->flush();
      }
      
      //qDebug()<<"Worker:: get called from?: "<<QThread::currentThreadId();
      

      }@

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Chrisw01
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bareil76
          wrote on last edited by
          #4

          Good idea.

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

          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