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. How to disable connection timer in QTcpSocket
Forum Updated to NodeBB v4.3 + New Features

How to disable connection timer in QTcpSocket

Scheduled Pinned Locked Moved Solved General and Desktop
qtcpsocketnetworkingqtimer
3 Posts 2 Posters 2.2k Views 1 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.
  • Y Offline
    Y Offline
    YuriQ
    wrote on 12 Feb 2016, 13:40 last edited by YuriQ 2 Dec 2016, 15:48
    #1

    Hello.
    QTcpSocket creates timer to handle connection timeout. I tried to use thousands of sockets (not a typicall use case, but anyway) and got this error messages:

    QEventDispatcherWin32::registerTimer: Failed to create a timer (The current process has used all of its system allowance of handles for Window Manager objects.)
    

    I think creating timer for every socket is huge wast of system resources when you use many sockets. I can handle timeouts manually using just one single timer. But I didn't find any option to disable built-in socket connection timer. How can do it?

    My environment: Qt 5.4, 5.5.1, Windows 8.1, Visual Studio 2013

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 12 Feb 2016, 22:56 last edited by SGaist
      #2

      Hi,

      AFAIK, there's none, you should have to modify QAbtractSocket and build your own version of Qt for that.

      But use a single timeout for so many sockets ? Sounds strange.

      Out of curiosity, why do you need so many sockets ?

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

      Y 1 Reply Last reply 15 Feb 2016, 10:42
      0
      • S SGaist
        12 Feb 2016, 22:56

        Hi,

        AFAIK, there's none, you should have to modify QAbtractSocket and build your own version of Qt for that.

        But use a single timeout for so many sockets ? Sounds strange.

        Out of curiosity, why do you need so many sockets ?

        Y Offline
        Y Offline
        YuriQ
        wrote on 15 Feb 2016, 10:42 last edited by
        #3

        @SGaist

        you should have to modify QAbtractSocket

        Seems like you right. The code in 'qabstractsocket.cpp':

        <...skipped...>
        // Start the connect timer.
        if (threadData->hasEventDispatcher()) {
            if (!connectTimer) {
                connectTimer = new QTimer(q);
                QObject::connect(connectTimer, SIGNAL(timeout()),
                                 q, SLOT(_q_abortConnectionAttempt()),
                                 Qt::DirectConnection);
            }
            connectTimer->start(QT_CONNECT_TIMEOUT);
        }
        <...skipped...>
        

        And there are no options to disable it. But I think it will be easy to patch it to make it work without connectTimer.

        But use a single timeout for thought of sockets ? Sounds strange.

        What else can I do to avoid handles exhaustion? I don't see any other options.

        Out of curiosity, why do you need so many sockets ?

        Just testing Qt abilities and limitations in this particular area.

        1 Reply Last reply
        0

        3/3

        15 Feb 2016, 10:42

        • Login

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