Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 547109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:56:17+00:00 2026-05-13T10:56:17+00:00

I am writing a chat program for my networking class and I have all

  • 0

I am writing a chat program for my networking class and I have all the networking setup perfectly.

My problem is if a client is currently writing a message and he receives a message from a different client then his current input gets displayed with the received message.

For example if a client is writing a message “Hi there how are you?” and receives a message “Good day to you!” while in the middle of writing their message it gets displayed as:

Hi there hoGood day to you!

->w are you?

Where -> is the area for the user to type in the message. What I would like to happen is to just display the message received and have the area -> retain all the previous text that was written before the message was received.

Please make note that what the client is typing in is still in fact “there” when he receives a message. If he completes his message his full message will be sent.

Also note that my client uses pthreads. One thread to read messages from the server and display them to the users screen and one thread to read from stdin and send the messages to the server. I do believe that my problem is arising because I am using pthreads and the threads share the same stdin, stdout, stderr. Maybe this is a misconception and wrong?

I hope I have been clear on my problem. If not, sorry. Please let me know what I can clarify for you.

I started doing some research and came upon these links:

  • ANSI Escape Characters
  • Thread from Stackoverflow

I was thinking about trying to go up lines and move the cursors around and stuff, but don’t know if that is the most effective way to do so. Firstly because I don’t know how to capture the information that is in the terminal waiting to “entered”/sent to stdin. Maybe I just haven’t found out how to do that.

Also I was wondering if there was a way to work/manipulate file descriptors to solve the problem? Maybe that wouldn’t even solve it?

Thanks for reading and your time. I appreciate all your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:56:17+00:00Added an answer on May 13, 2026 at 10:56 am

    Using a library such as curses to manage text ‘windows’ will be easier than trying to manipulate the screen by hand.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.