I'd avoid this route. Basically, it involves implementing a limited form of cooperative multitasking from scratch. Here are some examples:
Example with sentinel ("\n") terminated messages
Example with length-prefixed messages
Update: I've added replies to the examples linked above that show simpler alternatives to using select.
In reply to Re^2: non-blocking listen on a tcp server
by ikegami
in thread non-blocking listen on a tcp server
by monkeyfish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |