Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QUdpSocket stop receiving data
Qt 6.12 LTS is out! See what's new in the release blog

QUdpSocket stop receiving data

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 6 Posters 10.4k Views 2 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #4

    Hi guys,

    Thanks for the input. I think I have solved the issue. The threads are running fine. It turned out that, this problem occurs when I create the UDP socket in the worker thread class without passing its parent.

    i.e
    Instead of declaring :
    @QUdpSocket *socket = new QUdpSocket;@

    It should be:
    @QUdpSocket *socket = new QUdpSocket(this);@

    After fixing this, I could continuously receive data with a period of 25ms without any disruption.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ambershark
      wrote on last edited by
      #5

      That's kinda weird. I'm glad it's solved for now, but I can't really see any cases where having a parent would matter for receiving data.

      Especially since it would receive some but not all the data. Very weird indeed. Glad it's working though.

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #6

        Exactly. I find it very weird though. And I am still not sure how this could solve the problem. But I have tested more than once and it is no longer failing. If I remove the parent, it fails.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          ambershark
          wrote on last edited by
          #7

          Just out of curiousity, what type of object is "this"?

          My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #8

            "this" is just a class I created myself to receive and process the data. After processing, it emit signals by transmitting the data received as a parameter to some other class. I have inherited the class from QObject though and it runs in a worker thread

            1 Reply Last reply
            0
            • A Offline
              A Offline
              ambershark
              wrote on last edited by
              #9

              Hmm, so no reason there. Oh well, I'll stop thinking about it now since it's working for you. I just hate not knowing why something works, lol. :)

              My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #10

                Same here. :)

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  Hi,

                  Just an educated guess, you wrote that the socket is in a worker thread so I presume that it's a worker object that you used moveToThread on ? If so, the socket was not moved before since it wasn't parented to the worker object and thus was not in the correct thread to work.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #12

                    Yes, I used moveToThread from the main thread. That makes so much sense. Thanks SGaist

                    1 Reply Last reply
                    0
                    • SurizerS Offline
                      SurizerS Offline
                      Surizer
                      wrote on last edited by
                      #13

                      Hey is it possible to share how you are sending data from matlab to QT .How did you set up both environment? It would be nice if you can share something.

                      K 1 Reply Last reply
                      0
                      • SurizerS Surizer

                        Hey is it possible to share how you are sending data from matlab to QT .How did you set up both environment? It would be nice if you can share something.

                        K Offline
                        K Offline
                        koahnig
                        wrote on last edited by
                        #14

                        @Surizer
                        Hi and welcome to this forum

                        Just make you aware that the post is rather old. Furthermore from the user's profile you can see that the user might no longer hang out in the forum. His last activity was about 2 years according to his profile.

                        Possibly you start a new thread with a link to this thread here. May be someone else knows a solution.

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

                        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
                        • Unsolved