Implementation issues

Jun 19, 2013 at 11:26 AM
Dear Author,

I am working closely with the your FTP client and it works great, though I have some implementation issues, which I prefer your opinion.

1 When need to transfer (Write/Append) few files ( files total size can get up to 10gb) at a given ‘Task’, concerning transferring rate, how many channels (threads) will bring me to the best performance? (I know there is no definite answer here)
  1. What would be your approach to validate that a given file entirely transferred to the server? (exists + size.remote == size.local??)
Thanks,
Ziv
Coordinator
Jun 19, 2013 at 12:51 PM
The number transfers you can do at a time depends entirely on the bandwidth available to the client and the server. I can't give you an answer with regards to what will yield the best performance, it's something I'd have to try and observe.

With regards to verifying transfers, you have two options and you've already named one of them, compare file sizes. That's clearly not the best but in some cases it's the only way. If you check the Documentation page on this site you'll see that I added support for several non-standard hashing algorithms. You can query the FtpClient.Capabilities flags to see if any of them are implemented and if they are you can used the appropriate implementation. If they're not, you can fall back to just comparing sizes. An implementation might look something like this:
FtpHash hash = null;

if((hash = ftpClient.GetChecksum("/path/to/file")).IsValid) {
     // beware, an exception can be thrown here if the hash algorithm
     // the server used is not supported by the .net framework! as of
     // this time, SHA1, SHA256, SHA512 and MD5 are typically 
     // supported, CRC is NOT and in .net 2.0 only SHA1 and MD5 are available.

     if(!hash.Verify("some_local_file.ext"))
           throw new Exception("File validation failed, hashes do not match!");
}
else {
     if((new FileInfo("some_local_file.ext")).Length != ftpClient.GetFileSize("/path/to/remote/file"))
           throw new Exception("File validation failed, sizes do not match!");
}
As I mentioned, the hashing code is non-standard. Most servers are not going to implement any of them however some will. If you have the option, changing the server software to one that does might be best for your use-case. FileZilla server supports the HASH command as an experimental feature (you have to manually edit the config and enable it) and it's what I used to test the implementation. I've never tested any of the others, I don't know have access to systems that implement them. I just read as much as I could about them and wrote the code; no testing at all. I make no guarantees.
Jun 19, 2013 at 1:58 PM
Thanks!!!