When you share files on a network, you need some way to ensure that two people can't modify the same data at the same time. That's easy if you're not expecting two people to try to access one file at once. But with shared files, such as those ECCO uses, you need
sophisticated file locking
.
ECCO isn't record-oriented, so it can't use the type of locking found in most commercial databases. Instead, it usually (depending on the type of file) locks a file for as long as a client needs it and then unlocks it. This basic protocol is called OF_SHARE_DENY_NONE, which specifies that if the file is already open in another mode, a second open command should fail, but multiple
clients can open it in this mode. When the file is open, ECCO sets the first 16 bytes of the file as locked using the DOS FLOCK function (a DOS INT 21H function). Once all this is set up, only the locking process can read or write to the file.
File locking varies a little depending on the type of file you're opening. The most common scenario would run like this. You open a shared file. ECCO opens the shared file itself, loads it into memory on your machine, and then closes it. ECCO then opens a pair of shared status files and holds them open until you close the original file.
illustration_link (7 Kbytes)

ECCO sets u
p locked "channels" to ensure that only one instance of each local file can attach to the shared file.