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. Why udpsocket does not receive anything?

Why udpsocket does not receive anything?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 4.0k Views
  • 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.
  • S Offline
    S Offline
    shalongbasi
    wrote on 1 Mar 2013, 16:53 last edited by
    #1

    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 10.10.10.11, submask 10.10.10.255, gateway 10.10.10.1, 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 10.10.10.255. 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) :
    QWidget(parent),
    ui(new Ui::RemoteContol)
    {
    ui->setupUi(this);

    connect(ui->UpdateButton,SIGNAL(clicked()),this,SLOT(sendSettingParameters()));
    //udpSocket.bind(QHostAddress("10.10.10.11"),49166);
    connect(&udpSocket, SIGNAL(readyRead()), this, SLOT(processPendingData()));
    

    }

    void RemoteContol::sendSettingParameters(void)
    {
    QByteArray datagram;
    QDataStream out(&datagram,QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_4_8);
    out << "aaabbbccc";
    udpSocket.writeDatagram(datagram,QHostAddress("10.10.10.255"),55555);
    }

    void RemoteContol::processPendingData(void)
    {
    QByteArray datagram;
    do {
    datagram.resize(udpSocket.pendingDatagramSize());
    udpSocket.readDatagram(datagram.data(),datagram.size());
    } while (udpSocket.hasPendingDatagrams());
    }
    @

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on 1 Mar 2013, 17:02 last edited by
      #2

      Please use code wrappings as explained "in here.":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01
      This makes your code sample readable.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        shalongbasi
        wrote on 1 Mar 2013, 19:21 last edited by
        #3

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

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on 3 Mar 2013, 10:39 last edited by
          #4

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

          1 Reply Last reply
          0

          1/4

          1 Mar 2013, 16:53

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved