Search code examples
delphinetwork-programmingsynchronizationfile-copying

Delphi - Folder Synchronization over network


I have an application that connects to a database and can be used in multi-user mode, whereby multiple computers can connect the the same database server to view and modify data. One of the clients is always designated to be the 'Master' client. This master also receives text information from either RS232 or UDP input and logs this data every second to a text file on the local machine.

My issue is that the other clients need to access this data from the Master client. I am just wondering the best and most efficient way to proceed to solve this problem. I am considering two options:

  1. Write a folder synchronize class to synchronize the folder on the remote (Master) computer with the folder on the local (client) computer. This would be a threaded, buffered file copying routine.
  2. Implement a client/server so that the Master computer can serve this data to any client that connects and requests the data. The master would send the file over TCP/UDP to the requesting client.

The solution will have to take the following into account:

a. The log files are being written to every second. It must avoid any potential file locking issues.

b. The copying routine should only copy files that have been modified at a later date than the ones already on the client machine.

c. Be as efficient as possible

d. All machines are on a LAN

e. The synchronization need only be performed, say, every 10 minutes or so.

f. The amount of data is only in the order of ~50MB, but once the initial (first) sync is complete, then the amount of data to transfer would only be in the order of ~1MB. This will increase in the future

Which would be the better method to use? What are the pros/cons? I have also seen the Fast File Copy post which i am considering using.


Solution

  • If you use a database, why the "master" writes data to a text file instead of to the database, if those data needs to be shared?