the reason for having threads is simple : one thread has to wait on a line arriving from the user (client), respond to it, and repeat for ever. The other has to just report back autonomously every second. The responses seen at the client should look like this:
OK OK ? report: 27 OK ? report: 36 OK
With OK and ? being the responses to client commands. As you say, they are received by the same piece of code which parses them and acts appropriately. That's fine, and nothing to do with needing threads, which is a result of needing to both wait for user input AND act autonomously.
The simple solution, which I'll likely take, is juts to poll periodically from the client. I just liked the idea of being able to say "start reporting" ... "stop reporting" instead of that.
In reply to Re^2: sharing a socket between two threads (win32)
by danmcb
in thread sharing a socket between two threads (win32)
by danmcb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |