Reputation: 10037
how would I implement communication between Linux programs written in C? Specifically, I want the following:
My program can run in multiple instances. Upon startup, I want that my program detects all other instances of my program that are already running and then it should be able to send a text string to them. On the other hand, I also want that the instances that are already running get notified that a new instance has been started and they should also be able to send a text string to the new instance.
Could someone point me to some APIs which could be used to implement such a software design on Linux? On Windows, I can simply enumerate over all windows, check their class names to find out all instances of my program, and then register a custom message with the system that I can use to send data to them. But how would I do this on Linux?
Thanks for any hints!
Upvotes: 6
Views: 5170
Reputation: 796
You have a lot of options:
If it is for a standalone machine, and only one stream of data, I would recommend the option number 1.
Upvotes: 4
Reputation: 67831
I have used sockets and multicast for that very purpose. This allows distribution of processes among several computers on the same LAN.
Upvotes: 0
Reputation: 18282
Upvotes: 2