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. When using Multithreaded Server how can I constantly check for data sent from the server to the client?
QtWS25 Last Chance

When using Multithreaded Server how can I constantly check for data sent from the server to the client?

Scheduled Pinned Locked Moved General and Desktop
qtcpserverqnetworkqtcpsocketqthreadmulti clientmultithreads
6 Posts 3 Posters 2.9k 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.
  • J Offline
    J Offline
    Jakebrown05
    wrote on 13 Mar 2015, 22:52 last edited by
    #1

    I have a multi-threaded server which adds a new thread for every client that connects to the server.
    On the client Side I am trying to figure out the best way to constantly check for updated data from
    the server. I was thinking having a separate thread running on the client side that has a while(1) loop running constantly checking for new data written over the socket. Is this the correct way to do things with QT? Or should I do it using signals and Slots? I tried using those as well previously but it would not update unless the client sent something to the server first.

    The overall outcome I want is so that when one client sends information to the server all other clients are updated with the same information immediately. The server has a function that when it receives data it runs through a loop updating all the other clients. Just don't know how to do this with QT.

    Thanks in advance,

    Jake

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 13 Mar 2015, 23:22 last edited by
      #2

      Hi and welcome to devnet,

      For a thread server example, have a look at the Threaded Fortune Server example.

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

      J 1 Reply Last reply 13 Mar 2015, 23:32
      0
      • S SGaist
        13 Mar 2015, 23:22

        Hi and welcome to devnet,

        For a thread server example, have a look at the Threaded Fortune Server example.

        J Offline
        J Offline
        Jakebrown05
        wrote on 13 Mar 2015, 23:32 last edited by
        #3

        @SGaist Hey

        Thanks for the reply. I have been looking at that example. Im just not sure how the client side of things work though. My current server currently connects multiple clients but the problem is having the live update among all clients. Similar to that of a chat app where if one user says "Hello World" All other users on the server will receive the same message...

        Jake

        M 1 Reply Last reply 13 Mar 2015, 23:38
        0
        • J Jakebrown05
          13 Mar 2015, 23:32

          @SGaist Hey

          Thanks for the reply. I have been looking at that example. Im just not sure how the client side of things work though. My current server currently connects multiple clients but the problem is having the live update among all clients. Similar to that of a chat app where if one user says "Hello World" All other users on the server will receive the same message...

          Jake

          M Offline
          M Offline
          mcosta
          wrote on 13 Mar 2015, 23:38 last edited by
          #4

          @Jakebrown05 The client connect to the server using a TCP socket (or SLL) and read on it when the server needs to send something

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          J 1 Reply Last reply 14 Mar 2015, 01:03
          0
          • M mcosta
            13 Mar 2015, 23:38

            @Jakebrown05 The client connect to the server using a TCP socket (or SLL) and read on it when the server needs to send something

            J Offline
            J Offline
            Jakebrown05
            wrote on 14 Mar 2015, 01:03 last edited by
            #5

            @mcosta Does it read automatically ? or Is there a function that is called when something is sent across the socket?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mcosta
              wrote on 14 Mar 2015, 04:09 last edited by
              #6

              I suggest to use the readyRead() signal to be notified when some data arrive on the socket

              Once your problem is solved don't forget to:

              • Mark the thread as SOLVED using the Topic Tool menu
              • Vote up the answer(s) that helped you to solve the issue

              You can embed images using (http://imgur.com/) or (http://postimage.org/)

              1 Reply Last reply
              0

              6/6

              14 Mar 2015, 04:09

              • Login

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