multicast_socket/
lib.rs

1use std::net::Ipv4Addr;
2use std::time::Duration;
3
4#[cfg(windows)]
5mod win;
6#[cfg(windows)]
7pub use win::*;
8
9#[cfg(not(windows))]
10mod unix;
11#[cfg(not(windows))]
12pub use unix::*;
13
14pub struct MulticastOptions {
15    /// The maximal timeout before [`MulticastSocket::receive`] returns.
16    ///
17    /// If this is `None`, [`MulticastSocket::receive`] will block until there is data to read.
18    pub read_timeout: Option<Duration>,
19    pub loopback: bool,
20    pub buffer_size: usize,
21    /// The address to bind the socket to.
22    ///
23    /// Usually this will be Ipv4Addr::UNSPECIFIED, in order to listen for packets on all
24    /// interfaces.
25    pub bind_address: Ipv4Addr,
26}
27
28impl Default for MulticastOptions {
29    fn default() -> Self {
30        MulticastOptions {
31            read_timeout: Some(Duration::from_secs(1)),
32            loopback: true,
33            buffer_size: 512,
34            bind_address: Ipv4Addr::UNSPECIFIED,
35        }
36    }
37}