PDA

View Full Version : Problem in QTcpSocket



navi1084
16th October 2008, 06:20
Hi,
I am facing a problem in QTcpSocket.
I need to send consecutive separate packets in network. To send the packets i am using write operation followed by a flush and followed by write once again.
socket->write(data)
socket->flush()
socket->write(data1)
when i flush the packet and execute write of data1 , then first packet will be lost. If i remove the flush then in same packet data and data1 is passed .
I need to pass two packets separately without loosing any of them. Please can anyone tell me how can i accomplish it???

Thank You

kernel_panic
16th October 2008, 08:00
you cant do that this way. you know tcp is a stream, its continous sending data. use udp for data packages or build a package which contains the his own size, so the receiver can read a as many bytes as the packages size is.

kingslee
16th October 2008, 13:12
socket->write(data);
use waitForBytesWritten() in the middle .. wait until ' data' is written
and then
socket->write(data1);

cheers