Skip to main content

oko_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 nonblocking: bool,
20    pub loopback: bool,
21    pub buffer_size: usize,
22    /// The address to bind the socket to.
23    ///
24    /// Usually this will be Ipv4Addr::UNSPECIFIED, in order to listen for packets on all
25    /// interfaces.
26    pub bind_address: Ipv4Addr,
27}
28
29impl Default for MulticastOptions {
30    fn default() -> Self {
31        MulticastOptions {
32            read_timeout: Some(Duration::from_secs(1)),
33            nonblocking: false,
34            loopback: true,
35            buffer_size: 512,
36            bind_address: Ipv4Addr::UNSPECIFIED,
37        }
38    }
39}