Update 2024-03-27: Greatly expanded the "Samples" page and renamed it to "Glossary".
Update 2024-04-04: Added 5 million mid-2011 posts from the k47 post dump. Browse (mostly) them here.
Update 2024-04-07: Added ~400 October 2003 posts from 4chan.net. Browse them here.

Welcome to Oldfriend Archive, the official 4chan archive of the NSA. Hosting ~170M text-only 2003-2014 4chan posts (mostly 2006-2008).
[6 / 0 / ?]

[1396392193] wut

No.958866 View ViewReplyOriginalReport
dearest /prog/

I am trying to write an instant messaging program in C. I have come to a brick wall, however. how do I handle these three things concurrently: refreshing the display (in my case, a basic ncurses window), accepting input (stdin), writing & reading from the socket?

the main issue is that input blocks anything else from happening. is it possible to pass the file descriptor for stdin to another thread, then for that thread to update the char* array for the input ncurses window, then that is finally updated by the main thread? then, after the input is 'ready', it is written to the socket.

meanwhile, the read thread would accept and write data to a char** array, holding the data for the recent messages (which is then updated by the main thread thru ncurses windows).

am i thinking in any logical sense? how would you wizards accomplish this? also, to reiterate my question, could I pass the stdin file descriptor to another thread which then processes it?

thx