Results 1 to 5 of 5

Thread: QTCPSocket not getting all data

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    6
    Thanked 18 Times in 18 Posts

    Default Re: QTCPSocket not getting all data

    no mallocs, honest!
    OK, we're friends again!

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: QTCPSocket not getting all data

    Just to add:
    Large data packages don't has to be sent at once through TCP, so you can receive your data in many packages (every time readyRead() will be emitted) so just save expected data size (from that first 'special' package) and then in in slot on readyRead check with bytesAvailable() how many bytes received. If you got less then you are waiting for, then save all the data in some buffer (QByteArray or write directly to file but you can withour readLine() just write what readAll() returns), substract bytesAvailable from all required bytes count and keep waiting for another readyRead() and so on until you get all required data. Then you have complete package in your buffer.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

Similar Threads

  1. QTcpSocket + receiving data
    By navi1084 in forum Qt Programming
    Replies: 1
    Last Post: 2nd June 2009, 09:10
  2. Problem with reading in data from a QTCPSocket
    By Denarius in forum Qt Programming
    Replies: 4
    Last Post: 24th April 2009, 09:54
  3. Problem in printing the data return /read from QTcpsocket
    By skumar434 in forum Qt Programming
    Replies: 3
    Last Post: 20th February 2009, 20:36
  4. Corrupt JPEG data: premature end of data segment
    By node_ex in forum Qt Programming
    Replies: 1
    Last Post: 19th August 2008, 09:57
  5. QTcpSocket and data size - how do I know the size?
    By themolecule in forum Qt Programming
    Replies: 3
    Last Post: 28th August 2007, 02:19

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.