How to make a loop in console application.
-
I have a WebSocket server and a client. I created a loop inside main function of client program after creating WebSocket. I want to read from console and send messages to server. But my client does not connect to my server until exec() function of QCoreApplication is called.
What is the best or easiest way to do it.
-
Hi
You can use a QTimer to periodically run some code. -
@mrjj So if I singleshot to a function or lambda with QTimer, it will execute that when program reaches to exec()?
-
@maydin
yes it should. but single shot only runs once and it sounded more you wanted to to
more than one time. but else yes.@mrjj Using readLine() causes application to wait until pressing enter. Therefore I solved problem by using Timer with low timeouts.
But I am still not sure how Timer with 0 timeout runs my functions. Probably it waits until the function reaches to end before executing new one.
-
@mrjj Using readLine() causes application to wait until pressing enter. Therefore I solved problem by using Timer with low timeouts.
But I am still not sure how Timer with 0 timeout runs my functions. Probably it waits until the function reaches to end before executing new one.