fn broker(config: Config, brk: Arc<AtomicBool>) -> () {
    // create sockets
    let send_socket = Arc::new(UdpSocket::bind(config.sender_bind()).expect("Can't bind sender socket"));
    let recv_socket = Arc::new(UdpSocket::bind(config.receiver_bind()).expect("Can't bind sender socket"));
    config.vlog(&format!("Sockets created --> {} <--> {} --> {}", config.sender_bind(), config.receiver_bind(), config.receiver_addr()));

    // create sender part
    let from_sender = handle(
        Arc::clone(&send_socket),
        Arc::clone(&recv_socket),
        config.clone(),
        config.receiver_addr(),
        "BrokerFromSender",
        brk.clone(),
    );
    // create receiver part
    let from_receiver = handle(
        Arc::clone(&recv_socket),
        Arc::clone(&send_socket),
        config.clone(),
        config.sender_addr(),
        "BrokerFromReceiver",
        brk.clone(),
    );

    // wait for them to end
    from_sender.join().expect("Can't join thread from sender");
    from_receiver.join().expect("Can't join threads from receiver");
}
/// Creates the broker and spawn all the threads.
Creates the broker and spawn all the threads.
Creates the broker and spawn all the threads .
fn broker(config: Config, brk: Arc<AtomicBool>) -> () {
    // create sockets
    let send_socket = Arc::new(UdpSocket::bind(config.sender_bind()).expect("Can't bind sender socket"));
    let recv_socket = Arc::new(UdpSocket::bind(config.receiver_bind()).expect("Can't bind sender socket"));
    config.vlog(&format!("Sockets created --> {} <--> {} --> {}", config.sender_bind(), config.receiver_bind(), config.receiver_addr()));
    // create sender part
    let from_sender = handle(
        Arc::clone(&send_socket),
        Arc::clone(&recv_socket),
        config.clone(),
        config.receiver_addr(),
        "BrokerFromSender",
        brk.clone(),
    );
    // create receiver part
    let from_receiver = handle(
        Arc::clone(&recv_socket),
        Arc::clone(&send_socket),
        config.clone(),
        config.sender_addr(),
        "BrokerFromReceiver",
        brk.clone(),
    );
    // wait for them to end
    from_sender.join().expect("Can't join thread from sender");
    from_receiver.join().expect("Can't join threads from receiver");
}
fn broker ( config : Config , brk : Arc < AtomicBool > ) -> ( ) { // create sockets let send_socket = Arc :: new ( UdpSocket :: bind ( config . sender_bind ( ) ) . expect ( " " ) ) ; let recv_socket = Arc :: new ( UdpSocket :: bind ( config . receiver_bind ( ) ) . expect ( " " ) ) ; config . vlog ( & format ! ( " " config sender_bind ( ) config receiver_bind ( ) config receiver_addr ( ) ) ) ; // create sender part let from_sender = handle ( Arc :: clone ( & send_socket ) , Arc :: clone ( & recv_socket ) , config . clone ( ) , config . receiver_addr ( ) , " " , brk . clone ( ) , ) ; // create receiver part let from_receiver = handle ( Arc :: clone ( & recv_socket ) , Arc :: clone ( & send_socket ) , config . clone ( ) , config . sender_addr ( ) , " " , brk . clone ( ) , ) ; // wait for them to end from_sender . join ( ) . expect ( " " ) ; from_receiver . join ( ) . expect ( " " ) ; }
Creates the broker and spawn all the threads.
Creates the broker and spawn all the threads .
config
Config
brk
Arc<AtomicBool>
config
Config
brk
Arc<AtomicBool>