use std::net::SocketAddr;
use crossbeam::channel::{Sender, Receiver};
use zelda::{Socket, Config, Packet, Event};
let socket_address: SocketAddr = "127.0.0.1:38000".parse().unwrap();
let socket1 = Socket::bind(socket_address, Config::default())?;
let socket2 = Socket::bind_any(Config::default())?;
println!("Address of socket 2: {}", socket2.local_address());
let packet_sender: Sender<Packet> = socket2.packet_sender();
packet_sender.send(Packet::new(socket_address, "Hello, Client!".as_bytes().to_vec()));
let event_receiver: Receiver<Event> = socket1.event_receiver();
while let Ok(event) = event_receiver.recv() {
Event::Connected(addr) => {
},
Event::Received { address, payload, rtt, rtt_offset } => {
},
Event::Disconnected(addr) => {
break;
}
}
More examples in the repository.