Skip to content

A single-socket designed to multicast across multiple interfaces

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

bltavares/multicast-socket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

multicast-socket

Single-socket to network across multiple interfaces

This crate provides an abstract struct that allows a single-socket to listen and respond to multicast packets on multiple interfaces.

By default, when binding a regular std::net::UdpSocket to the unspecified ip 0.0.0.0, the socket will only send messages to what the OS considers the deafult interface. This is less than ideal on computers with multiple interfaces (a.k.a. 'multihomed') like laptops, cellphones, desktops with wifi, VPNs, Windows with WSL, Mac with Adapters and various common computer cenarios nowadays.

Instead of creating multiples sockets for each interface, and providing a multi-socket writer, this crate uses a couple of C/C++ OS-specific syscalls and methods to provide a single-socket multi-interface multicast experience.

The create also provides a utility constructor which uses get_if_addrs syscalls to find all available interfaces to bind to it, providing an out-of-the-box multicast multihomed experience.

The crate is designed with IPv4 in mind because I didn't have a test project to validate what IPv6 needs, and this is why the structs are IPv4 specific. If there is a suggestion on how to test this for IPv6, it could be expanded later.

Examples

cargo run --example mdns

Usage

[dependencies]
multicast-socket = "0.2.1"

Targets

Main tier:

  • x86_64-unknown-linux-gnu
  • x86_64-pc-windows-msvc
  • x86_64-apple-darwin

Cross tier:

  • armv7-unknown-linux-gnueabihf
  • aarch64-linux-android
  • mips-unknown-linux-musl
  • x86_64-unknown-linux-musl
  • aarch64-unknown-linux-gnu

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

References

About

A single-socket designed to multicast across multiple interfaces

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages