Add explanatory comments to exercise 258

This commit is contained in:
Emelie Graven 2022-04-04 08:21:07 +02:00
parent 6ff23340af
commit 7ad3a06072
Signed by: emelie
GPG key ID: C11123726DBB55A1

View file

@ -87,12 +87,14 @@ const REAL_NAME: &str = "dailyprog_2851";
fn main() -> Result<(), Box<dyn Error>> {
let mut stream = TcpStream::connect(SERVER)?;
// Send initial NICK and USER commands
stream.write_all((String::from("NICK ") + NICK + "\r\n").as_bytes())?;
stream.write_all(
(String::from("USER ") + USER_NAME + " 0 * :" + REAL_NAME + "\r\n").as_bytes(),
)?;
let mut reader = BufReader::new(stream);
let mut line = String::new();
// Loop indefinitely, printing any incoming messages to stdout and responding to PINGs
loop {
reader.read_line(&mut line)?;
println!("{}", &line);