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. :)
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.
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...
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. New file is placed in outgoing folder
- 2. Client sends file
- 3. Client calculates checksum
- 4. Server calculates checksum
- 5. Server sends checksum to client
- 6. Client compares both checksums
- 7. If the checksums are not the same, the process starts again at point 2
- 8. Client removes file
It will be some work to get the checksum calculation right, but it might just work.
Good luck!
Re: Best way to check if file is successfully sent over QTcpSocket
Quote:
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.
Re: Best way to check if file is successfully sent over QTcpSocket
Quote:
Originally Posted by
DrDonut
It will be some work to get the checksum calculation right, but it might just work.
Yeah, very hard work to get QCryptographicHash right. ;)