PDA

View Full Version : My QtcpServer lost message



ookawa kouji
19th March 2012, 07:08
I am deveropping TCPIP communication program.
My project send messege from one client to server.
But my project fail to receive same message.when It send with a short span.
If it send with a log span.It can receive all message.
Please tell me how to solve this probrem. 

To deverop it, I refer to fortune client server example.
My projects(both client and server) have MainWindow.
so I use it to connect QtcpSocket and Qtcpserver. is it bad?
Please tell me how to solve it.

wysota
19th March 2012, 11:37
You are falsely assuming that if you send two blocks of data then the receiver will receive the data as two blocks containing one message each. TCP has no concept of messages, it treats data as an opaque stream of octets. The receiver can receive all messages in one segment or each message can be divided into several segments. You should buffer all incoming data and analyze the buffer looking for message boundaries based on the application protocol you implemented on the sender side.