Skip to content

paulanthonywilson/otp-multicast-example

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

Using multicast with Elixir

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published