I'm working on a project where I'm required to make 2 processes (one written in C++ and the other in Python) talk asynchronously. Specifically they need to:
- Never use any kind of wait or sleep
- I have no way to determine whether one of the 2 processes will be ready to write or read
- Multithreading is not allowed
- Both are running in loop, so at the beginning of the loop they should call either a read or write function and viceversa when they reach the end of the loop
- Communication needs to be resilient: if the C++ process writes while the Python one is crashing, the data should be sent regardless and the Python process should retrieve said data after being rebooted
- The data sent won't be as simple as just sending signals. It's gonna be strings etc
- Zero tolerance for data loss
- Shared memory is off the table unless it's literally the ONLY available solution
At first I've been looking at FIFOs, however they seem to be unreliable: the resiliency is just not there (which is strange because it works when I try to make 2 C++ processes talk to each other while one of them has crashed) and many strings my C++ process is sending to the Python one are just completely lost for some reason. Finally, 2 way communication doesn’t seem to work at all unless I create 2 FIFOs, since the same process could read and write before the other has a chance to read
Now I'm looking at Unix Domain Sockets, but they seem to be used for synchronous communication only.
I'd need some guidance to understand whether I'm misusing the FIFOs (aka: FIFOs are actually compliant with my requests and I'm just doing something wrong) or UDS are a viable option or there are actually other available solutions.