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