Multicasting
Example repo for post on using UDP Multicast with OTP.
This will broadcast the OS hostname to any multicast listeners on port 49001 on 239.2.3.4. It will also listen on that post and user the logger to print out those messages from the local node or any peers on the network.
Usage (assuming an Elixir installation)
Setup:
mix deps.get
Running
iex -S mix
There is Dockerfile for running in Docker to illustrate communicating between nodes - as we can't bind to the same address/port on the same OS.
Usage (if you have Docker installed)
./bin/docker-run.sh
or
docker build -t multicast . && docker run -it multicast iex -S mix
When running multiple nodes you can then see the peer details received by running
iex(1)> Multicasting.registered_peers()
[{"c5d10bc2f914", {172, 17, 0, 3}}]
You may need to wait to see results: the nodes broadcast every 15 seconds, and the entries will expire after 35 seconds, if not refreshed.