Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One way would be to set a flag when the user first starts typing a line of text -- then if you receive data from the network while that flag is set, simply queue up the received data in some local data structure (i.e. don't print it yet) until the local user presses return. When the local user presses return, then you would print out all the data that you had queued up while he was typing, and unset the flag.</p> <p>Of course that approach has several disadvantages: </p> <ul> <li>If the local user enters some text and never presses return, he'll never see any incoming remote text. That could be a problem e.g. if the user presses space and walks away.</li> <li>The cin/stdin functionality in C/C++ usually work on a per-line basis, and you would need to set the terminal to raw/non-canonical mode to get it to report when the local user has entered just a character (rather than buffering up characters until the local user pressed return, and then reporting the whole line of text to your program at once)</li> </ul> <p>The other approach would be to keep the local user's text and the remote user's text in physically separate areas (e.g. top and bottom halves of the window, like many chat programs do). To do that will require more control than the vanilla C/C++ stdin/stdout/cin/cout API gives you; you'd need to either create a GUI window (using Win32 or Qt or some other GUI API) with two separate text-widgets, or if you want to keep everything inside an MS-DOS window, you might uses something like <a href="http://pdcurses.sourceforge.net">PDCurses</a> to implement that.</p> <p>Either of those options will be non-trivial, though -- they will likely take more time and effort to implement than the rest of your chat application. If it was me, and the chat application was only a learning exercise, I'd be temped to simply document the current behavior as a "known limitation" and not worry about fixing it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload