views:

136

answers:

2

...for use in a multithreaded network server.

I want to pass data around between multiple threads. Currently I'm using sockets, with the master thread blocking on select() and workers blocking on recv(), though I feel there probably are more advanced or prepackaged ways of handling this task in C++.

+2  A: 

You can try the ACE library which ships with pipes and message queues which are specially suited for inter-thread communication.

*ACE stands for Adaptive Communication Environment

f4
+3  A: 

I would have worker threads waiting in a thread pool.

Then the master waiting on select (for both reads and writes).

As data comes the master adds jobs to the thread pool. As each job is added a thread wakes up executes the job and returns to the pool. This way you are not blocking threads waiting on specific ports with recv() and a fixed set of child threads can handle all incoming traffic.

Currentl libs that support this functionality in ready made objects:

Martin York