Bigger(more than GB) file transfer by TCP socket program?



  • Hi,
    I am newbie for QT & try to learn how to send file one pc to another by QT program.
    I found QtFileClient & QtFileServer.
    both program helps to understand how file transfer one PC to another by qt program (by setting proper IP address & port).
    But I cant send bigger than 20 kb file by this program.
    Is this program wrong or for sending bigger file there is different method?
    My aim is to send mp4 or img files which in GB!
    Expert guidance needed.
    Thanks


  • Moderators

    Why can't you send file bigger than 20kb? What is the problem/error message? As far as I can see the file is send in chunks of 5000 bytes.



  • Thanks jsulm,
    I download one pdf from link.
    Try to use it for my program.
    output of client program as below:-

    Starting /home/mkhire/workplaces/QT_workplace/build-FileClient-Desktop_Qt_5_5_1_GCC_64bit-Debug/FileClient...
    "/home/mkhire/Downloads/rfc2543.pdf"
    "rfc2543.pdf"
    463051
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 5000
    ToSend: 3051
    

    output of server program as below:-

    Starting /home/mkhire/QT_examples/build-FileServer-Desktop_Qt_5_5_1_GCC_64bit-Debug/FileServer...
    "The server is running!"
    "We have a new connection!"
    "rfc2543.pdf"
    "463051"
    bytesAvailable: 21803
    bytesAvailable: 16799
    bytesAvailable: 11795
    bytesAvailable: 6791
    bytesAvailable: 1787
    bytesAvailable: 21845
    bytesAvailable: 21408
    bytesAvailable: 65052
    bytesAvailable: 65052
    bytesAvailable: 65483
    bytesAvailable: 129673
    bytesAvailable: 73116
    

    I found that file transfer & it size 20kb which not useful.
    There is NO Error message or problem for below 20kb file. I doesnt understand why these two program not transfer bigger file than 20 kb while I does not edit single line in this program?
    Thanks.


  • Lifetime Qt Champion

    Hi,

    You can send files bigger than 20Kb however, you have to handle that also on the receiving by buffering the data until you have received everything. Since you have big files, you'll likely start writing to the disk before you received all the data from the sender.

    To do that, you should also send to the receiving end the size of what you are sending to him. Or establish a protocol to split your upload in chunks. That might make your transfer more error proof. Take for example Amazon's S3 chunked upload.

    You should take a look at Qt's fortune server and client examples.


  • Moderators

    @Mandar-Khire I don't understand why you think file > 20kb is not working. The output of client and server looks good. Did you check the PDF file stored by the server? Compare it to the original file.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.