views:

70

answers:

2

I am just curious about this.

I had a network folder open on one computer viewing the files in the folder. From another computer I opened the same folder on the network and deleted a file. On the first computer the deleted file immediate disappeared from the list.

The only way that I can think of how it knows that is that it is constantly checking the contents of the open folder. But that sounds like it would waste a lot of resources to do, but I cannot think of any other way it could do that. So I was just wondering...how does that work?

Thanks.

+1  A: 

It's probably a push notification. Rather that the client computer constantly checking, the server sends a message to the client when a change is made.

Bravery Onions
A: 

You never specified what platform you're interested in. In general, the only thing that is portable is polling to see when a file or directory has been updated. Polling once a second or so is generally not too expensive, though over a network file system it may be too much.

Various platforms offer a variety of solutions for being notified when filesystems change. Moder versions of Linux provide inotify. Mac OS X provides the FSEvent system. On Windows there is a directory change notification system.

Brian Campbell