3

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.

CODE:

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");
}
Community
  • 1
  • 1
Mare Infinitus
  • 8,024
  • 8
  • 64
  • 113
  • Have you considered a more high level framework, like a self-hosted SignalR for your broadcast needs? – Hylaean Aug 21 '14 at 13:40
  • I need something that is available in C#, Java and python at least. Will investigate SignalR – Mare Infinitus Aug 21 '14 at 13:41
  • Regarding the high-level framework - I recommend WCF, you declare communication interface and you don't have to care about background implementation (it can be named pipes, http, tcp ...) – Ondrej Svejdar Aug 21 '14 at 13:51
  • WCF is not available in Java, python, ... – Mare Infinitus Aug 21 '14 at 13:57
  • Is UDP an option? You would obviously need to deal with dropped packets. – Daniel Kelley Aug 21 '14 at 14:17
  • What I want is communication with one process. The problem right now is that I cannot tell which process will get the message, so for a quick and dirty solution I wanted the message to be received by all processes. Seems I have to rethink the whole thing and rewrite it. – Mare Infinitus Aug 21 '14 at 14:22

1 Answers1

1

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

Community
  • 1
  • 1
bairog
  • 3,143
  • 6
  • 36
  • 54