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. QSslSocket::readyRead() signal is not raise after sending data ..
Forum Updated to NodeBB v4.3 + New Features

QSslSocket::readyRead() signal is not raise after sending data ..

Scheduled Pinned Locked Moved Solved General and Desktop
25 Posts 6 Posters 7.5k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #21

    You should take a look at the example provided in the QThread details documentation more specifically the one for the worker object implementation.

    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
    • R Offline
      R Offline
      Ritchie
      wrote on last edited by
      #22

      Hi,

      I am already using the first way, shown in the examples.

      But the documents says:

      A QThread object manages one thread of control within the program. QThreads begin executing in run(). By default, run() starts the event loop by calling exec() and runs a Qt event loop inside the thread.

      So, if I not execute the "Exec()" command, so far I understand, the QT Event Loop will not starts.

      But within the examples, there is no using any "exec()".

      It says for the first sample:

      The code inside the Worker's slot would then execute in a separate thread. However, you are free to connect the Worker's slots to any signal, from any object, in any thread. It is safe to connect signals and slots across different threads, thanks to a mechanism called queued connections.

      So in this case, no "exec()" is needed in the separate thread to execute ?

      And for the second sample it says

      In that example, the thread will exit after the run function has returned. There will not be any event loop running in the thread unless you call exec().

      Best regards
      R.

      1 Reply Last reply
      0
      • Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #23

        @Ritchie I'm assuming your "program" is a client connecting securely to a server, because you're using

        m_sslSocket->write(*block);
        m_sslSocket->flush(); 
        

        so I don't getting why you're expecting a readyRead() signal, since that will happen when you are reading data, not writing it. From Qt's documentation:

        void QIODevice::readyRead()

        This signal is emitted once every time new data is available for reading from the device's current read channel.

        Am I missing something? If so my apologies right now...

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        1
        • R Offline
          R Offline
          Ritchie
          wrote on last edited by
          #24

          @Pablo-J-Rogina
          You are right, the

          void QIODevice::readyRead()

          is only emitted after receiving bytes from the server.
          And after sending data's from the client to the server, the server will answer.

          Like "Data stored" correct or "Data not stored"

          Best regards
          R.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Ritchie
            wrote on last edited by
            #25

            Hi to all,

            I solved my problem by the following way.

            The function "DoWork" was change in the follwing way. Now it calls the QThread::exec() function.
            The loop function is done by a timer event.

            void DataThread::doWork(void)
            {
                ProgramInfo->writelog(QObject::tr("carclient"),QObject::tr("DataThread"),QObject::tr("Info"),QObject::tr("Thread startup"));
            
                if (! m_sslSocket->supportsSsl())
                    {
                    ProgramInfo->writelog(QObject::tr("carclient"),QObject::tr("DataThread"),QObject::tr("Failure"),QObject::tr("No support fpr SSL connection!"));
                    }
            
                m_WorkTimer = new QTimer();
                connect(m_WorkTimer, SIGNAL(timeout()), this, SLOT(DoTimerWork()));
                m_WorkTimer->start(50);
            
                QThread::exec();
            
                m_WorkTimer->stop();  // will delete later
            
               if( m_StateMachineState != NoConnection )
                {
                m_sslSocket->close();
                m_sslSocket->disconnectFromHost();
                }
                emit    WorkFinished();
            }
            

            Within the function "DoTimerWork", I do the cyclic stuff and do not block the events anymore

            void    DataThread::DoTimerWork(void)
            {
                if( SensorQueryBuffer->Size() > 0 )
                    {
                    if ( ! SensorQueryBuffer->locked() )
                        {
                        if (m_sslSocket->state() != QTcpSocket::ConnectedState)
                            {
                            if( m_StateMachineState == NoConnection )
                                {
                                m_StateMachineState=TryToConnect;
                                m_sslSocket->connectToHostEncrypted(m_ServerTCPIPAddress, m_ServerTCPIPPort);
                                }
                            }
                        }
                    }
            }
            
            

            Thanks to all try to help me.

            Best regards
            R.

            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