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. Does listen() method runs in another thread?
Qt 6.11 is out! See what's new in the release blog

Does listen() method runs in another thread?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.3k 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.
  • mandruk1331M Offline
    mandruk1331M Offline
    mandruk1331
    wrote on last edited by
    #1

    Does the listen method runs in a different thread or I have to create a new thread and call the listen method there?

    Mandruk1331

    J.HilkJ 1 Reply Last reply
    0
    • mandruk1331M mandruk1331

      Does the listen method runs in a different thread or I have to create a new thread and call the listen method there?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @mandruk1331 listen() runs in the same thread as the object listen() belonges to. I you have for example a QTcpServer that listens for connections, listen runs in the same thread as your QTcpServer.

      That means once every Eventloop it will check for new connections and emit the signal, if there are any.

      So if you block your thread with a heavy duty operation your TcpServer will not react to new connections, during that operation.

      My advice, if you can, than run your server in a different thread.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      mandruk1331M 1 Reply Last reply
      2
      • J.HilkJ J.Hilk

        @mandruk1331 listen() runs in the same thread as the object listen() belonges to. I you have for example a QTcpServer that listens for connections, listen runs in the same thread as your QTcpServer.

        That means once every Eventloop it will check for new connections and emit the signal, if there are any.

        So if you block your thread with a heavy duty operation your TcpServer will not react to new connections, during that operation.

        My advice, if you can, than run your server in a different thread.

        mandruk1331M Offline
        mandruk1331M Offline
        mandruk1331
        wrote on last edited by
        #3

        @J.Hilk Thank you! That's what I wanted to know.

        Mandruk1331

        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