When using Multithreaded Server how can I constantly check for data sent from the server to the client?
-
wrote on 13 Mar 2015, 22:52 last edited by
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
-
Hi and welcome to devnet,
For a thread server example, have a look at the Threaded Fortune Server example.
-
Hi and welcome to devnet,
For a thread server example, have a look at the Threaded Fortune Server example.
wrote on 13 Mar 2015, 23:32 last edited by@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
-
@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
wrote on 13 Mar 2015, 23:38 last edited by@Jakebrown05 The client connect to the server using a TCP socket (or SLL) and read on it when the server needs to send something
-
@Jakebrown05 The client connect to the server using a TCP socket (or SLL) and read on it when the server needs to send something
wrote on 14 Mar 2015, 01:03 last edited by@mcosta Does it read automatically ? or Is there a function that is called when something is sent across the socket?
-
wrote on 14 Mar 2015, 04:09 last edited by
I suggest to use the
readyRead()
signal to be notified when some data arrive on the socket
2/6