Qt World Summit: Submit your Presentation

Strange things with QSslSocket (Qt 4.7.4)

  • Hello.
    Following code hangs up:

    @requestData(); // ask server for some data
    socket_->waitForReadyRead( -1 );@

    But following code works fine:

    while( !socket_->waitForReadyRead( 1 ) )
    socket_->peek( 1 ); // {1}
    QCoreApplication::processEvents(); // {2}

    Without {1} or {2} second piece of code doesn't work too. How QSslSocket::peek() can influence on QSslSocket::waitForReadyRead()? QSslSocket's readyRead() signal connected to some monitoring slot (and with the first snippet this slot is never invoked).
    I've tried QxtSignalWaiter as well but with no luck (but QxtSignalWaiter works fine with QFtp's get() and commandFinished()).
    Can someone explain me why this happens?

    I'm trying to implement synchronous class (Client) for ssl connection so, let's say, QString Client::getData( QString request ) should send request string to some server and wait for data to return to a caller. Maybe there is a better way (or already written code) for such thing?

    P.S.: Sorry for my English.

  • Just did some hack. Got relevant code from QxtSignalWaiter and added there
    @socket_->peek( 1 );@
    Works well but i hate such boilerplate. Still waiting for better solutions and explanations about peek().

Log in to reply