Results 1 to 3 of 3

Thread: Sending large base64 string over qtcpsocket

  1. #1
    Join Date
    Apr 2016
    Posts
    9
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Sending large base64 string over qtcpsocket

    I want to send files over my qtcpsocket. It also needs to read some text. I am right now using base64. Small files work fine but large file are send in 2 parts for some reason. My read function only reads the first part so only about half of the image is visible when I get it. Does anyone knows a good way to send large files over my qtcpsocket? I still have to read some text because sending files is not the only function. I am receiving the string with the readReady signal en I get it with socket->readAll();
    Last edited by jwz104; 13th April 2016 at 21:31.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Sending large base64 string over qtcpsocket

    This is normal behaviour - You live with it

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Sending large base64 string over qtcpsocket

    A TCP connection is conceptually a byte stream, that gets chopped into packets by the network stack, transmitted to the peer and then reassembled.
    The data blocks that arrive can be different sized chunks than what the sender wrote into the socket.

    E.g. if a sender writes individual bytes, the receiver might still receive them in mulitbyte blocks.
    Or like in your case, writen large blocks can end up being received as a number of smaller blocks.

    You will need a protocol that either lets you know beforehand how many bytes belong to one "object" or a way to detect the end of data of one "object".

    Cheers,
    _

Similar Threads

  1. Replies: 2
    Last Post: 6th December 2014, 09:56
  2. sending a file(txt,docs,exe,rar,zip...) through QTcpSocket
    By toufic.dbouk in forum Qt Programming
    Replies: 3
    Last Post: 29th December 2012, 17:03
  3. Sending mp3 files over QTcpSocket
    By ada10 in forum Newbie
    Replies: 5
    Last Post: 17th August 2010, 08:05
  4. Sending large datagrams(very large)
    By marcel in forum General Programming
    Replies: 1
    Last Post: 16th February 2008, 21:55
  5. Compress and Uncompress large files in QTcpSocket
    By vishesh in forum Qt Programming
    Replies: 4
    Last Post: 26th June 2007, 22:21

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.