i have written a tcp/ip chat program but i have a problem. On client program while user writing message, a background thread receives messages from an other client and writes the message to terminal. The problem arises when client starts typing message and before he/she presses the return key incoming message overlaps the message. How can i prevent this. Is it possible to write incoming message without overlapping the message being written?
Typically, this is solved by using curses http://en.wikipedia.org/wiki/Curses_(programming_library) to write the messages in a different part of the terminal than where the input is being typed in.