https://github.com/bltavares/multicast-socket
A single-socket designed to multicast across multiple interfaces
https://github.com/bltavares/multicast-socket
Last synced: about 1 month ago
JSON representation
A single-socket designed to multicast across multiple interfaces
- Host: GitHub
- URL: https://github.com/bltavares/multicast-socket
- Owner: bltavares
- License: apache-2.0
- Created: 2020-06-28T21:47:06.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-27T15:06:13.000Z (about 1 year ago)
- Last Synced: 2025-03-28T15:51:47.663Z (about 2 months ago)
- Language: Rust
- Size: 44.9 KB
- Stars: 13
- Watchers: 3
- Forks: 9
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# 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
```sh
cargo run --example mdns
```## Usage
```toml
[dependencies]
multicast-socket = "0.2.1"
```## Targets
Main tier:
- x86_64-unknown-linux-gnu
- x86_64-pc-windows-msvc
- x86_64-apple-darwinCross 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
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)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
-
-
-
-
-
-