I have a task to write multithreaded network chat for Linux, and I have got a question: how to I broadcast single message to every thread? I thought about either getting pipe for each thread in main thread, or getting single pipe for all threads. In my opinion second variant is better, but the problem is that you can't read same data from pipe multiple times and you can't lseek it.
So, the question is: is there any way to organize communication by file descriptor and read from it just like recv with MSG_PEEK does? Or am I following the wrong way?