pub fn start_broadcasting() -> std::io::Result<()> {
    info!("Starting broadcast loop...");

    let socket = UdpSocket::bind("0.0.0.0:0")?;
    socket.set_broadcast(true)?;
    socket.set_write_timeout(Some(Duration::from_secs(10)))?;

    thread::spawn(move || loop {
        // Sleep first, so the server has time to bootstrap.
        thread::sleep(Duration::from_secs(10));

        let result = socket.send_to("Hello, I am Irro!\n".as_bytes(), BROADCAST_ADDR);
        if let Err(error) = result {
            panic!("Error while sending broadcast UDP packet: {}", error);
        }

        info!("Broadcast sent to {}.", BROADCAST_ADDR);
    });

    Ok(())
}
/// Start a new thread sending periodic broadcast messages (in IPv4 network).
Start a new thread sending periodic broadcast messages (in IPv4 network).
Start a new thread sending periodic broadcast messages ( in IPv4 network ) .
pub fn start_broadcasting() -> std::io::Result<()> {
    info!("Starting broadcast loop...");
    let socket = UdpSocket::bind("0.0.0.0:0")?;
    socket.set_broadcast(true)?;
    socket.set_write_timeout(Some(Duration::from_secs(10)))?;
    thread::spawn(move || loop {
        // Sleep first, so the server has time to bootstrap.
        thread::sleep(Duration::from_secs(10));
        let result = socket.send_to("Hello, I am Irro!\n".as_bytes(), BROADCAST_ADDR);
        if let Err(error) = result {
            panic!("Error while sending broadcast UDP packet: {}", error);
        }
        info!("Broadcast sent to {}.", BROADCAST_ADDR);
    });
    Ok(())
}
pub fn start_broadcasting ( ) -> std :: io :: Result < ( ) > { info ! ( " " ) ; let socket = UdpSocket :: bind ( " " ) ? ; socket . set_broadcast ( true ) ? ; socket . set_write_timeout ( Some ( Duration :: from_secs ( 10 ) ) ) ? ; thread :: spawn ( move | | loop { // Sleep first, so the server has time to bootstrap. thread :: sleep ( Duration :: from_secs ( 10 ) ) ; let result = socket . send_to ( " \n " . as_bytes ( ) , BROADCAST_ADDR ) ; if let Err ( error ) = result { panic ! ( " " error ) ; } info ! ( " " BROADCAST_ADDR ) ; } ) ; Ok ( ( ) ) }
Start a new thread sending periodic broadcast messages (in IPv4 network).
Start a new thread sending periodic broadcast messages ( in IPv4 network ) .