I am trying to make a simple chat application in c++. And it works but, If someone enters something while someone else is typing. It like writes over what they were typing. I linked pictures as examples below.

The code I am using for the client and the server can be found here:

[Client](https://github.com/topkiller/networking/blob/master/Client.cpp)

[Server](https://github.com/topkiller/networking/blob/master/Server.cpp)

Pictures:

Before
![enter image description here](https://i.stack.imgur.com/H69OB.png)
After
![enter image description here](https://i.stack.imgur.com/Rl2XQ.png)