I want to make a application in C on Linux where there are multiple processes running on one computer, which come from the same binary. It is not exactly defined how many of these processes there will be (2-20). I want them to find all the other running instances of the binary when they start up. The processes should communicate over UDP with Linux Sockets and when one application sends a packet every process should receive it.
At the moment i have set up some basic udp message sending between two clients with fixed predefined ports. The goal ist to have them start up and get some port assigned from the os. The applications then should find other instances of the same binary and communicate with them. How can implement this sort of searching ? At first i tried to make them all listen to some fixed port via SO_REUSEADDR, but then just the last process to start up will receive all traffic. Then i looked into Multi and Broadcasting, but i think i need different ips for that to work.
Thanks in advance