Search code examples
delphishared-memorydelphi-2006mailslot

Sharing a common memory area in Delphi between PCs


I have a Delphi 2006 app that gathers data and displays it as a summary of many channels, one channel per row on a TDrawGrid. I have the same app running on various other PCs on the network, but these other PC's are slaves - they don't gather data but merely provide a remote display of the summary.

At present, the slaves just show a mimic of the summary display screen on the master, and this is implemented via broadcasts by way of mailslots from the master.

I want to implement this in a different way, to reduce the load on the master, and provide the slaves with a bit more flexibility and independence on how they interpret the data. Also, I am having issues with mailslot broadcast of the data across subnets.

Can I use some shared memory scheme to lay the data down to a memory-mapped file where the slaves can have access from anywhere (over the web, even)? We are talking about a memory size of 100k bytes max, say, updated by the master at around once per second, probably in a thread, to keep the master foreground task responsive.


Solution

  • The simplest way is using a file on a share that the master writes to and the slaves only read. Some kind of synchronization might be necessary, if you want to prevent "dirty reads". On the other hand, it might not matter, depending on the kind of data you want to display.

    Using a simple file has the advantage that it does not require any additional software (e.g. a daetabase server or some middleware) following the KISS principle. But of course it is far from sexy ;-) and does not use the correct buzzword technology.