Reputation: 8182
For simple IPC I have chosen NamedPipes to communicate between process (local).
Due to changing requirements there shall be multiple instances of the server, which leads to multiple "listeners" on the same pipename.
But there seems to be a problem. Only one of those listeners gets the message, every other instance does not. Is there some way of "broadcasting" messages?
I already have seen this question, which is basically the same question, but it has no answer.
Right now I use the pipeserver very similar to this answer
My client (in this case sender) code is:
public static void SendToPipe(string pipeName, string data)
{
using (var p = new NamedPipeClientStream(pipeName))
{
p.Connect();
using (var w = new StreamWriter(p))
{
w.WriteLine(data);
w.Flush();
}
}
}
respectivly:
static void Main(string[] args)
{
SendToPipe("DEFAULT_PIPE_NAME", "Some string to transmit");
}
Upvotes: 4
Views: 2576
Reputation: 3373
Finally I've found a solution (don't sure it's optimal - but it's working). It is based on using NamedPipeClientStream.NumberOfServerInstances. Look at my question thread
Upvotes: 1