Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am working in a small project using Qt
My program is a client, connected to server.
I use QTcpSocket.
C++
connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(handleData()));

Client receives data from server in 2 cases :
+) Case 1: Server always send its status
Client receives and only show them.
+) Case 2: When client wants to get some information, client will send a command.
Server will parse the command and return proper informations.
I want that client must wait for receiving data in TIMEOUT seconds.

Because I am using SIGNAL readyRead(), data will be received in another thread.
I can't wait for receiving data from server in case 2.

Can anyone suggest me some ideals ?
Thanks !
Posted

you will just have to save what was the last request the client sent (case 1 or 2), and when the data comes back from the server, process it and signal it to the next level.
 
Share this answer
 
You can emit custom signal when bytes are read and is being connected.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900