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. UDP reset
Forum Updated to NodeBB v4.3 + New Features

UDP reset

Scheduled Pinned Locked Moved Solved General and Desktop
32 Posts 4 Posters 3.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.
  • V Offline
    V Offline
    Vijaykarthikeyan
    wrote on last edited by
    #8

    @JonB The reason why i have used msleep is that without msleep the receiving data is not in sync with sender side..the process_response() is another sort of code to send back the acknowledgement. Without msleep,it is sedning acknowledgement more than needed,,So, msleep is needed for synchronization. process_response won't have any effect to this current question.

    jsulmJ JonBJ 2 Replies Last reply
    0
    • V Vijaykarthikeyan

      @JonB The reason why i have used msleep is that without msleep the receiving data is not in sync with sender side..the process_response() is another sort of code to send back the acknowledgement. Without msleep,it is sedning acknowledgement more than needed,,So, msleep is needed for synchronization. process_response won't have any effect to this current question.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #9

      @Vijaykarthikeyan Qt is an asynchronous framework and you should use it as such instead of using endless loops and msleep. Connect a slot to readyRead signal and read the data there (as @JonB pointed out).
      "So, msleep is needed for synchronization" - no, it's not. Use Qt like it is supposed to be used...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      V 1 Reply Last reply
      1
      • V Vijaykarthikeyan

        @JonB The reason why i have used msleep is that without msleep the receiving data is not in sync with sender side..the process_response() is another sort of code to send back the acknowledgement. Without msleep,it is sedning acknowledgement more than needed,,So, msleep is needed for synchronization. process_response won't have any effect to this current question.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #10

        @Vijaykarthikeyan
        What @jsulm and I are trying to explain is that to program properly with Qt you need to change your mindset.

        In the "traditional", synchronous approach you are presently using code does things like "wait" for data to arrive and "sleep" to cause delays. This "blocks" execution while the waits, sleeps etc. are going on.

        Qt has an "event-driven", asynchronous paradigm. Code should not "wait" or "sleep", it should be "non-blocking". You don't wait for data to arrive: Qt emits readyRead() signal when data does arrive and you act on that with whatever data has arrived so far. If it's not enough, you keep what you have so far and the next readyRead() tells you when more has arrived. If you need to "sleep", you set off a QTimer. That emits a timeout() signal when it expires, and you act on it at that point.

        It takes a little time to get used to this way round of programming if you are accustomed to the synchronous way. But after a bit it becomes quite natural. If you want to understand and take advantage of Qt programming you need to adjust to this approach.

        V 1 Reply Last reply
        1
        • jsulmJ jsulm

          @Vijaykarthikeyan Qt is an asynchronous framework and you should use it as such instead of using endless loops and msleep. Connect a slot to readyRead signal and read the data there (as @JonB pointed out).
          "So, msleep is needed for synchronization" - no, it's not. Use Qt like it is supposed to be used...

          V Offline
          V Offline
          Vijaykarthikeyan
          wrote on last edited by
          #11

          @jsulm Received datagram from "::ffff:192.168.0.110" : 55000 - "10.22,27.6,30.4,0,0,12.34456678"
          "0,S,M,A,0,0,S,S,4000,10000,#"
          "0,S,M,A,0,0,S,S,4000,10000,#"
          Received datagram from "::ffff:192.168.0.110" : 55000 - "10.22,27.6,30.4,0,0,12.34456678"
          Received datagram from "::ffff:192.168.0.110" : 55000 - "10.22,27.6,30.4,0,0,12.34456678"
          "0,S,M,A,0,0,S,S,4000,10000,#"
          "0,S,M,A,0,0,S,S,4000,10000,#"
          Received datagram from "::ffff:192.168.0.110" : 55000 - "10.22,27.6,30.4,0,0,12.34456678"
          "0,S,M,A,0,0,S,S,4000,10000,#"
          Received datagram from "::ffff:192.168.0.110" : 55000 - "10.22,27.6,30.4,0,0,12.34456678"
          "0,S,M,A,0,0,S,S,4000,10000,#"
          Received datagram from "::ffff:192.168.0.110" : 55000 - "10.22,27.6,30.4,0,0,12.34456678"
          "0,S,M,A,0,0,S,S,4000,10000,#"
          Received datagram from "::ffff:192.168.0.110" : 55000 - "10.22,27.6,30.4,0,0,12.34456678"
          "0,S,M,A,0,0,S,S,4000,10000,#"
          Received datagram from "::ffff:192.168.0.110" : 55000 - "10.22,27.6,30.4,0,0,12.34456678"
          "0,S,M,A,0,0,S,S,4000,10000,#"
          Received datagram from "::ffff:192.168.0.110" : 55000 - "10.22,27.6,30.4,0,0,12.34456678"
          "0,S,M,A,0,0,S,S,4000,10000,#"
          Received datagram from "::ffff:192.168.0.110" : 55000 - "10.22,27.6,30.4,0,0,12.34456678"
          "0,S,M,A,0,0,S,S,4000,10000,#"
          Received datagram from "::ffff:192.168.0.110" : 55000 - "10.22,27.6,30.4,0,0,12.34456678"
          Received datagram from "::ffff:192.168.0.110" : 55000 - "10.22,27.6,30.4,0,0,12.34456678"
          "0,S,M,A,0,0,S,S,4000,10000,#"
          "0,S,M,A,0,0,S,S,4000,10000,#"

          see,on other side,the data is printing double sometimes when we don't use msleep as per your suggestion. It is not correct when receving 2 sides. that's why i used msleep

          1 Reply Last reply
          0
          • JonBJ JonB

            @Vijaykarthikeyan
            What @jsulm and I are trying to explain is that to program properly with Qt you need to change your mindset.

            In the "traditional", synchronous approach you are presently using code does things like "wait" for data to arrive and "sleep" to cause delays. This "blocks" execution while the waits, sleeps etc. are going on.

            Qt has an "event-driven", asynchronous paradigm. Code should not "wait" or "sleep", it should be "non-blocking". You don't wait for data to arrive: Qt emits readyRead() signal when data does arrive and you act on that with whatever data has arrived so far. If it's not enough, you keep what you have so far and the next readyRead() tells you when more has arrived. If you need to "sleep", you set off a QTimer. That emits a timeout() signal when it expires, and you act on it at that point.

            It takes a little time to get used to this way round of programming if you are accustomed to the synchronous way. But after a bit it becomes quite natural. If you want to understand and take advantage of Qt programming you need to adjust to this approach.

            V Offline
            V Offline
            Vijaykarthikeyan
            wrote on last edited by
            #12

            @JonB ok..I'll correct it,but I can't get it what you have suggested for reset the program if data is not received. readyRead() is non retunable function,what else can we do with that

            JonBJ jsulmJ 2 Replies Last reply
            0
            • V Vijaykarthikeyan

              @JonB ok..I'll correct it,but I can't get it what you have suggested for reset the program if data is not received. readyRead() is non retunable function,what else can we do with that

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #13

              @Vijaykarthikeyan said in UDP reset:

              reset the program if data is not received

              Sorry, but this just doesn't mean very much. Don't know what you're trying to do why. You can either call reset() or simply discard some already-received data if that is what you want to do. You can tell if some particular time has passed since data last received via a QTimer if you need that.

              readyRead() is non retunable function,what else can we do with that

              Again, don't know quite how to answer. readyRead() is a signal. No, it does not "return" a result, that's not how signals work. You connect() a slot function to the signal and that gets called each time new data is received. As said several times, in the slot you accumulate data received and act on it when you have enough bytes for whatever you want.

              V 1 Reply Last reply
              1
              • V Vijaykarthikeyan

                @JonB ok..I'll correct it,but I can't get it what you have suggested for reset the program if data is not received. readyRead() is non retunable function,what else can we do with that

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #14

                @Vijaykarthikeyan said in UDP reset:

                readyRead() is non retunable function,what else can we do with that

                Please read and learn https://doc.qt.io/qt-6/signalsandslots.html , else it makes no sence to use Qt...

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                V 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @Vijaykarthikeyan said in UDP reset:

                  readyRead() is non retunable function,what else can we do with that

                  Please read and learn https://doc.qt.io/qt-6/signalsandslots.html , else it makes no sence to use Qt...

                  V Offline
                  V Offline
                  Vijaykarthikeyan
                  wrote on last edited by
                  #15

                  @jsulm Screenshot 2023-08-09 153201.png

                  Please read and learn https://doc.qt.io/qt-6/qiodevice.html#readyRead , else it makes no sense to use Qt...

                  its a udpsocket readyRead(),please go through it

                  jsulmJ 1 Reply Last reply
                  0
                  • V Vijaykarthikeyan

                    @jsulm Screenshot 2023-08-09 153201.png

                    Please read and learn https://doc.qt.io/qt-6/qiodevice.html#readyRead , else it makes no sense to use Qt...

                    its a udpsocket readyRead(),please go through it

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #16

                    @Vijaykarthikeyan Funny reply.
                    I know what readyRead is, but you apparently do not know what a signal is and how to use it. That's why I gave you the link. But it is up to you to learn and understand Qt basics or not, I'm out...

                    "its a udpsocket readyRead()" - QUdpSocket is a subclass of QIODevice...

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    V 2 Replies Last reply
                    0
                    • JonBJ JonB

                      @Vijaykarthikeyan said in UDP reset:

                      reset the program if data is not received

                      Sorry, but this just doesn't mean very much. Don't know what you're trying to do why. You can either call reset() or simply discard some already-received data if that is what you want to do. You can tell if some particular time has passed since data last received via a QTimer if you need that.

                      readyRead() is non retunable function,what else can we do with that

                      Again, don't know quite how to answer. readyRead() is a signal. No, it does not "return" a result, that's not how signals work. You connect() a slot function to the signal and that gets called each time new data is received. As said several times, in the slot you accumulate data received and act on it when you have enough bytes for whatever you want.

                      V Offline
                      V Offline
                      Vijaykarthikeyan
                      wrote on last edited by Vijaykarthikeyan
                      #17

                      @JonB no..u misunderstood my question..its a udpSocket->readyRead();

                      Here is my modified code:

                      #include <QCoreApplication>
                      #include <QTextStream>
                      #include <QtNetwork/QUdpSocket>
                      #include <QObject>
                      #include <QThread>
                      #include <QtSerialPort>
                      #include <QtSerialPort/qserialportinfo.h>
                      #include <QSerialPortInfo>
                      QUdpSocket *udpSocket;
                      QTextStream output(stdout);
                      QByteArray datagram,datagram2="10.22,27.6,30.4,0,0,12.34456678";
                      QHostAddress senderAddress2;
                      quint16 senderPort2;
                      QSerialPort *serial;
                      QString portname;
                      quint16 vendorId;
                      quint16 productId;
                      QTimer *timer;
                      
                      void reset_again();
                      
                      void send_reply()
                      {
                          int bytes=udpSocket->writeDatagram(datagram2, senderAddress2, senderPort2);
                          if(bytes)
                          {
                              qDebug()<<"Data is successfully sent to" << senderAddress2.toString() << ":" << senderPort2 << "-" <<datagram2;
                          }
                      }
                      void process_response() {
                          if (udpSocket->state() == QUdpSocket::BoundState)
                          {
                              while (udpSocket->hasPendingDatagrams()) {
                      
                      
                                  datagram.resize(udpSocket->pendingDatagramSize());
                                  QHostAddress senderAddress;
                                  quint16 senderPort;
                                  int bytesRead = udpSocket->readDatagram(datagram.data(), datagram.size(), &senderAddress, &senderPort);
                      
                                  QString data = QString::fromUtf8(datagram);
                      
                                  qDebug() << "Received datagram from" << senderAddress.toString() << ":" << senderPort << "-" << data;
                                  if (bytesRead == -1)
                                  {
                                      qDebug() << "Failed to read datagram!";
                                  }
                                  //udpSocket->reset();
                                  senderAddress2 = senderAddress;
                                  senderPort2=senderPort;
                                  send_reply();
                                  QThread::msleep(100);
                              }
                          }
                      }
                      
                      int main()
                      {
                          output << "UDP Command Prompt is ready to receive data!" << "\n";
                          udpSocket = new QUdpSocket();
                          timer = new QTimer();
                          serial=new QSerialPort();
                      
                          udpSocket->bind(QHostAddress::Any, 55000);
                      
                      
                          if(QObject::connect(udpSocket, &QUdpSocket::readyRead,udpSocket, &process_response)) {
                              //process_response();
                              QThread::msleep(100);
                          }
                          
                          else
                          {
                              QObject::connect(timer,&QTimer::timeout,&reset_again);
                              timer->setInterval(2000);
                          }
                          return 0;
                      }
                      
                      void reset_again()
                      {
                          main();
                      }
                      
                      
                      
                      
                      jsulmJ 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @Vijaykarthikeyan Funny reply.
                        I know what readyRead is, but you apparently do not know what a signal is and how to use it. That's why I gave you the link. But it is up to you to learn and understand Qt basics or not, I'm out...

                        "its a udpsocket readyRead()" - QUdpSocket is a subclass of QIODevice...

                        V Offline
                        V Offline
                        Vijaykarthikeyan
                        wrote on last edited by Vijaykarthikeyan
                        #18

                        @jsulm And I know what it is and how it works.. but you don't even know the intention. If i didn't learned the basics, i couldn't came to this way. In this forum,most of the suggestions failed..i found the solutions myself . First, learn Qt basics and how to treat the help seekers..

                        This code never exist in any of the examples.. I have built a user interface which does not exist in any example.

                        1 Reply Last reply
                        0
                        • jsulmJ jsulm

                          @Vijaykarthikeyan Funny reply.
                          I know what readyRead is, but you apparently do not know what a signal is and how to use it. That's why I gave you the link. But it is up to you to learn and understand Qt basics or not, I'm out...

                          "its a udpsocket readyRead()" - QUdpSocket is a subclass of QIODevice...

                          V Offline
                          V Offline
                          Vijaykarthikeyan
                          wrote on last edited by
                          #19

                          @jsulm Have you answered for my debug output question where i have mentioned it is printing 2 times.. firstly..dont run away with that question

                          1 Reply Last reply
                          0
                          • V Vijaykarthikeyan

                            @JonB no..u misunderstood my question..its a udpSocket->readyRead();

                            Here is my modified code:

                            #include <QCoreApplication>
                            #include <QTextStream>
                            #include <QtNetwork/QUdpSocket>
                            #include <QObject>
                            #include <QThread>
                            #include <QtSerialPort>
                            #include <QtSerialPort/qserialportinfo.h>
                            #include <QSerialPortInfo>
                            QUdpSocket *udpSocket;
                            QTextStream output(stdout);
                            QByteArray datagram,datagram2="10.22,27.6,30.4,0,0,12.34456678";
                            QHostAddress senderAddress2;
                            quint16 senderPort2;
                            QSerialPort *serial;
                            QString portname;
                            quint16 vendorId;
                            quint16 productId;
                            QTimer *timer;
                            
                            void reset_again();
                            
                            void send_reply()
                            {
                                int bytes=udpSocket->writeDatagram(datagram2, senderAddress2, senderPort2);
                                if(bytes)
                                {
                                    qDebug()<<"Data is successfully sent to" << senderAddress2.toString() << ":" << senderPort2 << "-" <<datagram2;
                                }
                            }
                            void process_response() {
                                if (udpSocket->state() == QUdpSocket::BoundState)
                                {
                                    while (udpSocket->hasPendingDatagrams()) {
                            
                            
                                        datagram.resize(udpSocket->pendingDatagramSize());
                                        QHostAddress senderAddress;
                                        quint16 senderPort;
                                        int bytesRead = udpSocket->readDatagram(datagram.data(), datagram.size(), &senderAddress, &senderPort);
                            
                                        QString data = QString::fromUtf8(datagram);
                            
                                        qDebug() << "Received datagram from" << senderAddress.toString() << ":" << senderPort << "-" << data;
                                        if (bytesRead == -1)
                                        {
                                            qDebug() << "Failed to read datagram!";
                                        }
                                        //udpSocket->reset();
                                        senderAddress2 = senderAddress;
                                        senderPort2=senderPort;
                                        send_reply();
                                        QThread::msleep(100);
                                    }
                                }
                            }
                            
                            int main()
                            {
                                output << "UDP Command Prompt is ready to receive data!" << "\n";
                                udpSocket = new QUdpSocket();
                                timer = new QTimer();
                                serial=new QSerialPort();
                            
                                udpSocket->bind(QHostAddress::Any, 55000);
                            
                            
                                if(QObject::connect(udpSocket, &QUdpSocket::readyRead,udpSocket, &process_response)) {
                                    //process_response();
                                    QThread::msleep(100);
                                }
                                
                                else
                                {
                                    QObject::connect(timer,&QTimer::timeout,&reset_again);
                                    timer->setInterval(2000);
                                }
                                return 0;
                            }
                            
                            void reset_again()
                            {
                                main();
                            }
                            
                            
                            
                            
                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #20

                            @Vijaykarthikeyan said in UDP reset:

                            void reset_again()
                            {
                            main();
                            }

                            Why are you calling main() here?! Never saw such thing. Don't do that!
                            In main you connect a slot to readyRead. That means: after each reset you will have one more connection and your slot will be called more than once. You also instantiate udp socket, timer and serial port there every time you call main(), so you also have a memory leak.
                            Also, remove the QThread::msleep(100); as already explained and start Qt event loop in main instead (like in almost every Qt application)! The code you posted is really strange, sorry for writing this, but you should really fix it.

                            What do you actually want to "reset" and why?

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            V 1 Reply Last reply
                            0
                            • jsulmJ jsulm

                              @Vijaykarthikeyan said in UDP reset:

                              void reset_again()
                              {
                              main();
                              }

                              Why are you calling main() here?! Never saw such thing. Don't do that!
                              In main you connect a slot to readyRead. That means: after each reset you will have one more connection and your slot will be called more than once. You also instantiate udp socket, timer and serial port there every time you call main(), so you also have a memory leak.
                              Also, remove the QThread::msleep(100); as already explained and start Qt event loop in main instead (like in almost every Qt application)! The code you posted is really strange, sorry for writing this, but you should really fix it.

                              What do you actually want to "reset" and why?

                              V Offline
                              V Offline
                              Vijaykarthikeyan
                              wrote on last edited by Vijaykarthikeyan
                              #21

                              @jsulm Acutally,this code is a part of receiver,another part is the sender which sends the data asynchronously..we don't get the data ,indeed the correct data all the time. If there is no data or any data get corrupted during transmission, this receiver should reset means it should enter/restarts the main loop again which is an alternative to app.exec(). Delay is not a big problem.So, ignore any event loop delays which are all caused by msleep and all.

                              this is the requirement which I'm trying to figure out. For sometimes it works.

                              So,instead of the event loop app.exec(), i want to do some condition to run that event loop

                              JonBJ 1 Reply Last reply
                              0
                              • V Vijaykarthikeyan

                                @jsulm Acutally,this code is a part of receiver,another part is the sender which sends the data asynchronously..we don't get the data ,indeed the correct data all the time. If there is no data or any data get corrupted during transmission, this receiver should reset means it should enter/restarts the main loop again which is an alternative to app.exec(). Delay is not a big problem.So, ignore any event loop delays which are all caused by msleep and all.

                                this is the requirement which I'm trying to figure out. For sometimes it works.

                                So,instead of the event loop app.exec(), i want to do some condition to run that event loop

                                JonBJ Offline
                                JonBJ Offline
                                JonB
                                wrote on last edited by
                                #22

                                @Vijaykarthikeyan
                                You have decided that you know how to write the Qt program your way, and don't seem to like the advice you are getting here. Best of luck.

                                In this forum,most of the suggestions failed..i found the solutions myself .

                                Then you have discovered that the suggestions here are worthless and you would be best sticking to finding the solutions for yourself. Nobody wants to suggest stuff to be told it's not appreciated.

                                FWIW, calling main() again won't work right.

                                V 1 Reply Last reply
                                0
                                • JonBJ JonB

                                  @Vijaykarthikeyan
                                  You have decided that you know how to write the Qt program your way, and don't seem to like the advice you are getting here. Best of luck.

                                  In this forum,most of the suggestions failed..i found the solutions myself .

                                  Then you have discovered that the suggestions here are worthless and you would be best sticking to finding the solutions for yourself. Nobody wants to suggest stuff to be told it's not appreciated.

                                  FWIW, calling main() again won't work right.

                                  V Offline
                                  V Offline
                                  Vijaykarthikeyan
                                  wrote on last edited by
                                  #23

                                  @JonB For sometimes calling main() works successfully.Whenever I raised the topic you guys never take that question and giving feedbacks about someother topics which is irrelevant to the topic. Even in this question, my question is to reset the udp whenevr there is no data is coming.But, you are accusing me about the code. If that was my problem,why shouldn't i raised that topic? because that's not the problem which im seeking to? still you guys ain't directly answering the question. If you know the answer,please tell that afterwards you can accuse me

                                  JonBJ Christian EhrlicherC 2 Replies Last reply
                                  0
                                  • V Vijaykarthikeyan

                                    @JonB For sometimes calling main() works successfully.Whenever I raised the topic you guys never take that question and giving feedbacks about someother topics which is irrelevant to the topic. Even in this question, my question is to reset the udp whenevr there is no data is coming.But, you are accusing me about the code. If that was my problem,why shouldn't i raised that topic? because that's not the problem which im seeking to? still you guys ain't directly answering the question. If you know the answer,please tell that afterwards you can accuse me

                                    JonBJ Offline
                                    JonBJ Offline
                                    JonB
                                    wrote on last edited by JonB
                                    #24

                                    @Vijaykarthikeyan
                                    Nobody has "accused" you of anything, or been impolite. Merely trying to help.

                                    I have already asked a couple of times what you mean by "reset the UDP", maybe if you answered that it would help. If you want to discard any data already received then do so. If you want to close the socket and re-open it then do so. If you want to destroy the UDP socket object and create a new one afresh then do so. No call to main() a second time.

                                    V 1 Reply Last reply
                                    1
                                    • V Vijaykarthikeyan

                                      @JonB For sometimes calling main() works successfully.Whenever I raised the topic you guys never take that question and giving feedbacks about someother topics which is irrelevant to the topic. Even in this question, my question is to reset the udp whenevr there is no data is coming.But, you are accusing me about the code. If that was my problem,why shouldn't i raised that topic? because that's not the problem which im seeking to? still you guys ain't directly answering the question. If you know the answer,please tell that afterwards you can accuse me

                                      Christian EhrlicherC Online
                                      Christian EhrlicherC Online
                                      Christian Ehrlicher
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #25

                                      There is no thing like a 'reset' for an udp connection. If you want a timeout use a QTimer as already told you. Everything else was already told - don't block the qt's event loop but use proper signals and slots. Or use another framework which does not need a running event loop (if you did one).

                                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                      Visit the Qt Academy at https://academy.qt.io/catalog

                                      V 1 Reply Last reply
                                      2
                                      • JonBJ JonB

                                        @Vijaykarthikeyan
                                        Nobody has "accused" you of anything, or been impolite. Merely trying to help.

                                        I have already asked a couple of times what you mean by "reset the UDP", maybe if you answered that it would help. If you want to discard any data already received then do so. If you want to close the socket and re-open it then do so. If you want to destroy the UDP socket object and create a new one afresh then do so. No call to main() a second time.

                                        V Offline
                                        V Offline
                                        Vijaykarthikeyan
                                        wrote on last edited by
                                        #26

                                        @JonB As I already told @jsulm again explaining my issue. resetting the udp means instead of auto calling the event loop by app.exec(), there should be some condition to enter /restart the event loop. no worry about the delays.

                                        Acutally,this code is a part of receiver,another part is the sender which sends the data asynchronously..we don't get the data ,indeed the correct data all the time. If there is no data or any data get corrupted during transmission, this receiver should reset means it should enter/restarts the main loop again which is an alternative to app.exec(). Delay is not a big problem.So, ignore any event loop delays which are all caused by msleep and all.

                                        this is the requirement which I'm trying to figure out. For sometimes it works.

                                        So,instead of the event loop app.exec(), i want to do some condition to run that event loop

                                        Christian EhrlicherC 1 Reply Last reply
                                        0
                                        • V Vijaykarthikeyan

                                          @JonB As I already told @jsulm again explaining my issue. resetting the udp means instead of auto calling the event loop by app.exec(), there should be some condition to enter /restart the event loop. no worry about the delays.

                                          Acutally,this code is a part of receiver,another part is the sender which sends the data asynchronously..we don't get the data ,indeed the correct data all the time. If there is no data or any data get corrupted during transmission, this receiver should reset means it should enter/restarts the main loop again which is an alternative to app.exec(). Delay is not a big problem.So, ignore any event loop delays which are all caused by msleep and all.

                                          this is the requirement which I'm trying to figure out. For sometimes it works.

                                          So,instead of the event loop app.exec(), i want to do some condition to run that event loop

                                          Christian EhrlicherC Online
                                          Christian EhrlicherC Online
                                          Christian Ehrlicher
                                          Lifetime Qt Champion
                                          wrote on last edited by Christian Ehrlicher
                                          #27

                                          There is no need for restarting the main event loop. It will not automagically re-sync something.
                                          Also udp is stateless. If you want more you have to create your own protocol on top of udp or even better tcp.

                                          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                          Visit the Qt Academy at https://academy.qt.io/catalog

                                          V 1 Reply Last reply
                                          1

                                          • Login

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