Quote:
|
could i use select() in my IM instead of threads
|
I've already detailed what select does....
And, as I'm sure you've taken the time to research threads, you understand their functionality.
What do you think?
A thread, simply put, allows you code to execute in a non-linear way. It allows for the appearence of simultaneous execution of two seperate sections of code. So, in your case, you could be executing a loop that is waiting for a message and one that sends a message (when appropriate) at the 'same time'.
However, you now must deal with shared variables, mutexes and race conditions (among other things).
You can do what you want (well, acheive the same result) without using threads. It wont be because of how you use select. Your design details what is required. If you wish to avoid threads, a redesign may be in order.
And, as an aside, I would suggest you NOT use the timeout feature of select. 30 seconds worth of non-interaction isn't unheard of. You don't (at least I don't) want an error in that case. If I'm not mistaken, a chat window may stay open indefinately, if the user so desires.