SocketTools provides methods that allow an application to verify that the contents of a file on the local system are the same as a file on the server. This can be used to either ensure that a file was uploaded correctly, or to check whether or not a file should be downloaded. For example, an application could check to see if the contents of a local file were the same as a remote file the user has requested to download, and if they match, the application knows it's not necessary to download the file again.
The file verification is performed using one of several methods, depending on what features the server supports. There are three general options available when performing file verifications using FTP: an MD5 hash, a CRC-32 checksum or a file size comparison. If the server supports the XMD5 command, then this is used to generate an MD5 hash and compare it against the local file; if the hash value matches, then the contents of the file are identical. If the server doesn't support this feature, a CRC-32 checksum can be generated in a similar fashion using the XCRC command to determine if the file contents are the same. If the FTP server doesn't support either MD5 or CRC-32, then a simple file size comparison can be performed.
By default, SocketTools will give preference to the MD5 hash, falling back to a CRC-32 checksum. If neither feature is supported by the server, then it will compare file sizes. Naturally, a file size comparison is the least reliable, so developers can specify if they only wish to use the MD5 and/or CRC-32 methods to determine if the file contents match.