PDA

View Full Version : Clear QTcpSocket buffer before using receiving new data



tbscope
12th May 2010, 19:45
I'm using a QTcpSocket to send a series of commands.

For one of the commands I want to limit the response buffer as I am only interested in the first two lines of the response.
So, just before I send this command, I limit the readBufferSize to a very low number (64 for example) and I use the readLine() function a couple of times.
This works very well.

But after I've finished with this command, I need to process the data for the next command. However, since I used readLine(), there's still some bytes in the socket buffer from the previous command. I didn't use the read() command to read the entire buffer.

My question now is, is there a way to clear the socket buffer before sending the next command?

I do have a solution though, just read the entire buffer with the read() command. But readLine is a little easier (read: I'm lazy) and I wondered if I could clear the remaining buffer.

tbscope
12th May 2010, 20:34
Never mind this question.

It's me who needs to stop the server from sending more bytes for the previous command.
Problem solved.

raviteja
26th February 2011, 06:50
hi tbscope..

i am also facing the same problem with socket write & read functions....
how can i clear or reset the previous buffer data.... help me out...



Thaks advance....