discovery 0.1.5

Service discovery via dns and vlan
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::io;
use tokio::net::UdpSocket;

pub async fn run_server(addr: &str) -> io::Result<()> {
    let socket = UdpSocket::bind(addr).await?;
    println!("Server running on {}", addr);

    let mut buf = [0; 1024];

    loop {
        let (len, addr) = socket.recv_from(&mut buf).await?;
        println!("Received from {}: {:?}", addr, &buf[..len]);

        let response = b"hello";
        socket.send_to(response, addr).await?;
    }
}