How to "CLEAR" data on QTcpSocket
Can I clear data on tcpSocket without read it ?
I tried like this but still not working.
Code:
qDebug() << myTcpSocket->size(); //result 3229696
myTcpSocket->reset();
qDebug() << myTcpSocket->size(); //result 3229696
If like this, is working. But, make a delay if data size is big.
Code:
qDebug() << myTcpSocket->size(); //result 3229696
myTcpSocket->readAll();
qDebug() << myTcpSocket->size(); //result 0
Thank's before..
Re: How to "CLEAR" data on QTcpSocket
To clear the buffer of the TCP socket, you need to read it.
But, if the socket can still receive data, it will fill the buffer again, and again, till everything is received. Thus, also close the connection before reading the buffer for the last time.
If the data is received in large blocks, you can set the read buffer size to receive smaller data blocks. This will generate more overhead that gets more significant the smaller the blocks are.