I'm looking for advice on the best, simplest IPC method for this scenario:
- Two programs on the same Linux server.
- Program 1 has a variable with an integer in it that is periodically updated to a different value, say every 1 second.
- Program 2 needs to periodically grab this value from Program 1. It just needs the latest value, not any queued ones.
- Neither reading or writing should block.
I've looked into named pipes, message queues, Unix domain sockets, and haven't been able to find a solution that works yet. I've made it work with a named pipe, but it blocks. When I try to use the nonblocking O_NDELAY flag to open the pipe for writing in Program 1, Program 2 only gets "0"s when reading.
Any general advice on how to best go about this?