blob: 63923665ea79f7c6cfe01eee63ab3cf6ebced2db (
plain) (
tree)
|
|
use std::net::{ToSocketAddrs, UdpSocket};
use crate::error::Error;
/// Sends a buffer on UDP broadcast
pub fn send_packet<A: ToSocketAddrs>(
bind_addr: A,
broadcast_addr: A,
buffer: &[u8],
) -> Result<usize, Error> {
let socket = UdpSocket::bind(bind_addr)?;
socket.set_broadcast(true)?;
Ok(socket.send_to(buffer, broadcast_addr)?)
}
|