I would like to rewrite some of my old programs to work on a home network. Basically have a shared data file in one location, such as NAS, that the same program on two different computers could access. Unfortunately, network programming is relatively new to me, and I'm not sure the best way to keep everything synced and avoid corruption.
I could simply lock the file when open and prevent the other program from accessing it till I'm done. At least I guess that would still work if the data was stored on a NAS or something similar? But in some of my programs that wouldn't really work very well as the data needs to read and write in real time, and locking the file could cause issues. Though I could probably work around that if needed.
Also, if one computer adds data to the file, how do I know the file has been updated to reload that data on the other computer? I suppose I could check the file periodically for changes, but that seems sloppy somehow. Is there a way for my app to be notified if the file has changed on an external network drive?
I also wonder what happens if I edit the same record on my computer as another person is editing it on the other computer. Who takes priority, and what happens with the other edit?
Any tips would be appreciated.
Thanks!
I could simply lock the file when open and prevent the other program from accessing it till I'm done. At least I guess that would still work if the data was stored on a NAS or something similar? But in some of my programs that wouldn't really work very well as the data needs to read and write in real time, and locking the file could cause issues. Though I could probably work around that if needed.
Also, if one computer adds data to the file, how do I know the file has been updated to reload that data on the other computer? I suppose I could check the file periodically for changes, but that seems sloppy somehow. Is there a way for my app to be notified if the file has changed on an external network drive?
I also wonder what happens if I edit the same record on my computer as another person is editing it on the other computer. Who takes priority, and what happens with the other edit?
Any tips would be appreciated.
Thanks!
Comment