Results 1 to 3 of 3

Thread: Clear QTcpSocket buffer before using receiving new data

  1. #1
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Clear QTcpSocket buffer before using receiving new data

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Clear QTcpSocket buffer before using receiving new data

    Never mind this question.

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

  3. #3
    Join Date
    Feb 2011
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Clear QTcpSocket buffer before using receiving new data

    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....

Similar Threads

  1. Replies: 4
    Last Post: 22nd March 2010, 18:32
  2. QTcpSocket slows down in receiving after several minutes
    By cutie.monkey in forum Qt Programming
    Replies: 1
    Last Post: 9th December 2009, 21:14
  3. QTcpSocket + receiving data
    By navi1084 in forum Qt Programming
    Replies: 1
    Last Post: 2nd June 2009, 08:10
  4. QTcpSocket readyRead and buffer size
    By pdoria in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2008, 10:11
  5. data at fifo's receiving end has arrived?
    By quickNitin in forum General Programming
    Replies: 4
    Last Post: 5th November 2006, 10:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.