Results 1 to 6 of 6

Thread: Best way to check if file is successfully sent over QTcpSocket

  1. #1
    Join Date
    Jul 2008
    Location
    Philippines
    Posts
    60
    Thanks
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Best way to check if file is successfully sent over QTcpSocket

    hi all,

    im currently doing a project on network file transfer. Im doing this using QTcpServer and QTcpSocket, e.i. I have a server and client application. Currently, ive been transfering files successfully, but sometimes some files are lost-due to network problems. The way i transfer file like this,
    1. My application always check for an outgoing folder.
    2. If there is a new file, i will open it using Qfile, then store the contents in a QByteArray
    3. Write the contents of the bytearray to the socket
    4. Finally, delete the file.

    Now, my question is, is there a way for me to determine if the receiver application successfully received data before i will finnaly delete the source file. Because during file transfer, network problems may occur. Thank you very much and i hope for your suggestions.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Best way to check if file is successfully sent over QTcpSocket

    You may consider using QNetworkAccessManager or QFtp which should do this work for you.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jul 2008
    Location
    Philippines
    Posts
    60
    Thanks
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Best way to check if file is successfully sent over QTcpSocket

    I have already created an application using QFtp, but my problem here is the transfer speed. So, i decided to convert it using TCP application which is faster in transfer speed - but here my problem is the accuracy coz as i have mentioned earlier some files are lost during file transfer. anyway thnks for ur suggestion...

  4. #4
    Join Date
    Mar 2008
    Posts
    27
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Best way to check if file is successfully sent over QTcpSocket

    This means that you should do the low-level transfer check yourself...

    You could do this for examle this way:
    1. 1. New file is placed in outgoing folder
    2. 2. Client sends file
    3. 3. Client calculates checksum
    4. 4. Server calculates checksum
    5. 5. Server sends checksum to client
    6. 6. Client compares both checksums
    7. 7. If the checksums are not the same, the process starts again at point 2
    8. 8. Client removes file


    It will be some work to get the checksum calculation right, but it might just work.

    Good luck!

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Best way to check if file is successfully sent over QTcpSocket

    but my problem here is the transfer speed
    Could you quantify the problem? (i.e how slow the transfer really is with QFtp in respect to your TCP solution?
    Its hard for me to imagine that your own protocol implementation will be that much more efficient (and still as good) as the Qt classes.

    How did you test the performance?
    Are you sure the performance bottle neck is not somewhere else in your application and not in the transfer it self?

    At any rate, as the poster before me wrote, if you are using a non protocoled connection you will have to implement some sort of a protocol to check your data.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. #6
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: Best way to check if file is successfully sent over QTcpSocket

    Quote Originally Posted by DrDonut View Post
    It will be some work to get the checksum calculation right, but it might just work.
    Yeah, very hard work to get QCryptographicHash right.

Similar Threads

  1. Check for invalid file name in QFileDialog
    By darren in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2008, 14:43
  2. Replies: 3
    Last Post: 11th September 2008, 20:08
  3. Check file is modified?
    By mamyte03@gmail.com in forum Qt Programming
    Replies: 6
    Last Post: 20th September 2007, 13:03
  4. Replies: 3
    Last Post: 29th June 2007, 08:32
  5. How to check a file for changes since last save
    By nmather in forum General Programming
    Replies: 2
    Last Post: 21st April 2007, 23:43

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.