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. waitForConnected() hangs my program !

waitForConnected() hangs my program !

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 660 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.
  • F Offline
    F Offline
    Francky033
    wrote on last edited by
    #1

    Hello,

    I have a major problem with the latest version of Qt (5.12.1)

    A simple function like this blocks the program under Windows 10 and Android. However, nothing to report on Linux and macOS.

    bool Internet::CheckConnection(QString server)
    {
    	QTcpSocket socket;
    	socket.setProxy(QNetworkProxy::NoProxy);
    	socket.connectToHost(server, 80);
    
    	// Renvoie false si pas connecté
    	rerun socket.waitForConnected(2000);
    }
    

    In addition, I see also important break times with code like that:

    reply3 = manager3->get(QNetworkRequest(url));
    
    	// Whenever more data is received from the network,
    	// this readyRead() signal is emitted
    	connect(reply3, SIGNAL(readyRead()),
    		this, SLOT(httpReadyRead3()));
    
    	// Also, downloadProgress() signal is emitted when data is received
    	//connect(reply, SIGNAL(downloadProgress(qint64, qint64)),
    	//	this, SLOT(updateDownloadProgress(qint64, qint64)));
    
    	// This signal is emitted when the reply has finished processing.
    	// After this signal is emitted,
    	// there will be no more updates to the reply's data or metadata.
    	connect(reply3, SIGNAL(finished()),
    		this, SLOT(httpDownloadFinished3()));
    
    	thread3->start();
    

    Nothing to report with Qt 5.12.0 and 5.11.3

    What should I do?

    Thanks !

    Francky033

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Francky033 said in waitForConnected() hangs my program !:

      bool Internet::CheckConnection(QString server)
      {
      QTcpSocket socket;
      socket.setProxy(QNetworkProxy::NoProxy);
      socket.connectToHost(server, 80);

      // Renvoie false si pas connecté
      rerun socket.waitForConnected(2000);
      }

      This will block 2 seconds when e.g. the server you want to reach is not available. And this function is somewhat useless - you're connecting to a socket but then deleting it as soon as it is connected...

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

      1 Reply Last reply
      2
      • F Offline
        F Offline
        Francky033
        wrote on last edited by
        #3

        Yes, this function only allows me to check, or not, the availability of a server. But the problem is that it doesn't answer after 5 minutes ! It's just an example of code....
        But since these are secure connections, maybe it's a version problem with the ssleay32.dll and libeay32.dll files?

        Which versions should be used with Qt 5.12.1 ?

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Francky033
          wrote on last edited by
          #4

          Maybe it is necessary to compile openssl in the version returned by QSslSocket::sslLibraryBuildVersionString and deliver the files libeay32.dll and ssleay32.dll with the executable?

          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