Results 1 to 2 of 2

Thread: QTcpSocket reading by chunk

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2007
    Posts
    24
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QTcpSocket reading by chunk

    Hello,

    With a "classic" network behaviour, a read() function must be -sometimes- called many times because packets aren't delivered in one chunk
    eg:

    Qt Code:
    1. int siz=2048;
    2. int len=siz;
    3.  
    4. while(len>0)
    5. {
    6. siz = read(socket, len); // returns number of bytes read
    7.  
    8. if (siz==0)
    9. return 1;
    10.  
    11. len-=siz;
    12. }
    To copy to clipboard, switch view to plain text mode 

    Now, with QTcpSocket, do I have the same "problem" or a simple
    Qt Code:
    1. sck.read(socket, len);
    To copy to clipboard, switch view to plain text mode 
    is enough to get all the data "len"gth ?


    Thanks
    Last edited by stef13013; 6th September 2012 at 19:44.

Similar Threads

  1. QTcpSocket can't read all bytes
    By Qiieha in forum Qt Programming
    Replies: 27
    Last Post: 23rd August 2011, 15:48
  2. QtcpSocket read behavior
    By grisson in forum Qt Programming
    Replies: 5
    Last Post: 14th August 2010, 16:31
  3. Replies: 1
    Last Post: 4th September 2009, 09:40
  4. read and write on qtcpsocket
    By dognzhe in forum Qt Programming
    Replies: 1
    Last Post: 2nd June 2009, 09:42
  5. Unable to read from QTcpSocket
    By jimroos in forum Qt Programming
    Replies: 1
    Last Post: 4th July 2007, 21:09

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.