Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions library/std/src/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ impl UdpSocket {
///
/// Note that this might not have any effect on IPv6 sockets.
///
/// Since the underlying socket option value is byte-sized,
/// any value above 255 will result in an error.
///
/// # Examples
///
/// ```no_run
Expand Down
10 changes: 4 additions & 6 deletions library/std/src/sys/net/connection/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,13 +759,11 @@ impl UdpSocket {
}

pub fn set_multicast_ttl_v4(&self, multicast_ttl_v4: u32) -> io::Result<()> {
let ttl: u8 = multicast_ttl_v4
.try_into()
.map_err(|_| io::Error::from(io::ErrorKind::InvalidInput))?;
unsafe {
setsockopt(
&self.inner,
c::IPPROTO_IP,
c::IP_MULTICAST_TTL,
multicast_ttl_v4 as IpV4MultiCastType,
)
setsockopt(&self.inner, c::IPPROTO_IP, c::IP_MULTICAST_TTL, ttl as IpV4MultiCastType)
}
}

Expand Down
Loading