PDA

View Full Version : QTcpSocket + receiving data



navi1084
2nd June 2009, 06:30
Hi all,
My Pc is connected to a host using TCP connection. My pc acts as client and host acts as server.
In a perticular case server should send two types of results/response. first result should contains large chunks of data and second is below 100 bytes. The problem occures when this data arrives at my pc. The problem is:
It can be seen that (using wireshark) all the datas sent by the server is reaching my pc( Both responses at once) whenever i request. But the first response will be received and triggers signal readyread() and i can extract the data. But 2nd response will trigger the signal readyread(), only when i request next time.

Steps:
1:Client: Request for the Data
2:Server: Sends two separate responses. Client will recieve successfully all the data(Checked using wireshark).
3: Client: Socket class triggers readReady() signal for first response. and extract the data.
4: Client: Socket class should trigger readReady() signal for second response. but it wont.
5: Client: Request for the Data:
6: Client: Socket class trigger readReady() signal for second response of previous request.
7: Client: Socket class triggers readReady() signal for first response of current request. and extract the data.
.
.
.

Can anyone tell me how can i resolve this problem such away that both responses evaluated in the same request.

yogeshgokul
2nd June 2009, 08:10
Hi Naveen,
I think, I know whats wrong here.

You checked with wireshark that data is coming to your PC at once not in two packets (big+small).
So this is the answer of your problem. That ReadyRead signal will emit only once, because data is coming only once.

You can read all data using socket->readAll().
You can check is there any data by socket->bytesAvailable().