}
// network functions
fn send_to(&self, buf: &str, addr: &SocketAddr) -> Option<usize> {
self.udp_socket.send_to(buf.as_bytes(), &addr).unwrap()
}
fn send_to_all(&self, buf: &str) -> Option<usize> {
let multicast_addr = SocketAddr::V4(SocketAddrV4::new(self.config.0, self.config.2));
self.send_to(buf, &multicast_addr)
}
fn recv_from(&self) -> Option<(String, SocketAddr)> {
let mut buf = [0; 256];
match self.udp_socket.recv_from(&mut buf).unwrap() {
Some((len, addr)) =>
Some((String::from(str::from_utf8(&buf[..len]).unwrap()), addr)),
None => None,
}