I am writing a basic chat server and client to test how TCP connections work in Rust. The problem I am having right now is that each time I receive output from the server, it isn't just the most recent chat I've sent, but rather the entire output I've already received:
Please enter your name.
Please enter your name.
Hayden has connected to server.
Please enter your name.
Hayden has connected to server.
Hayden says hello
Please enter your name.
Hayden has connected to server.
Hayden says hello
Hayden says goodbye
Can you post your code? Without seeing what you're doing it could be anything. You may be forgetting to clear your buffer before you read the TCP stream into it each time, for instance.
Mea culpa. I had forgotten that calls to BufReader::read_line don't replace the string they're passed but append to it. I was creating the string above the loop that reads from the clients, so the String just kept growing. Many thanks.