The client is a user program that is used to sync its files to the server replication module. The client creates a socket for end point communication with the server. Initially if the Client boots up after the crash recovery, the client is prompted to use “-recover” option to download all the files from the server repository. After this process the ClientD (Client Daemon) is synced with server’s repository, else the client populates its directory information using struct dirent. When the client populates the directory information, the client requests ServerD (Server Daemon) using REQ_DIRINFO message. The server in response sends all the files modified access time and file names. The ‘ClientD’ compares the files names and modified access time with its directory containing files. The ClientD creates upload list for all the files to be uploaded, modification list for the files whose diff is to be calculated and remove list for files to be removed from the server replica.
The ClientD is modularized into various functions such as follows:
● folder recover ( )
This module is used if the client boots after the crash and requests the server for all the files to be sent to maintain its own local copy.
usage: folder_recover (ServerIP, ServerPort, DirPath)
The first and second argument in the function is the ServerD’s IP address and Port no to which the client wishes to connect. The third parameter is the directory path that the ‘ClientD’ wishes to sync with.
● folder_sync ( )
This module is used if the client wishes to sync its files with server and requests the ‘ServerD’ to send the file name and its modified access time using REQ_DIRINFO message. In this module the client prepares a Upload_List, for uploading a file which is not present at Server’s repository, Modification_List if the client modifies the file contents and sends the diff of the file and Remove_List is the client wishes to delete a file from the directory.
usage: folder_sync (ServerIP, ServerPort, DirPath)
The first and second argument in the function is the ServerD’s IP address and Port no to which the client wishes to connect. The third parameter is the directory path that the ‘ClientD’ wishes to sync with.