I'm new to IPC using pipes and I'm not familiar with the usual patterns. Here is the setup I have to deal with: There is a client process that distributes work to n server processes. After finishing, the servers have to send their results back to the server. The amount of work that has to be distributed is known from the beginning.
Client
|__Pipe 1_____ Server 1
|
|__Pipe 2_____ Server 2
|
|__ ...
Here my idea, how to deal with this: The servers are started with a command line argument determining the name of the pipe they shall create when starting up. The client then writes to those pipes to distribute work. When the servers finish their job, they write their results to the pipe they received the job from. The client waits with n threads for the results from the servers. When all results arrived, the partial results are assembled.
Do you think this makes sense? Would you see advantages in using a single pipe in one of the directions? How would you synchronize access? Do you have reading tips on the topic?