#Problem with sending and receiving data using TcpStream
3 messages · Page 1 of 1 (latest)
broadcast function in server.rs on lines 77-90:
pub fn broadcast(&mut self, data: &str) {
let clients = self.clients.clone();
{
let mut clients = clients.lock().unwrap();
for (name, value) in &mut *clients {
println!("broadcasting to {}", name);
value.send(data);
}
}
println!("done broadcasting");
}
send function in socket.rs on lines 107-117:
pub fn send(&mut self, data: &str) {
println!("trying to send data");
{
self.stream
.lock()
.unwrap()
.write_all(data.as_bytes())
.unwrap();
}
println!("succefully sent");
}