NamedPipe & InterprocessConnection


#1

Hi all,

should it be possible to send messages between processes with a NamedPipe?
As far as I understand the documentation it should, but I can’t send anything to the JuceDemo with the following code:

void sendText()
{
  NamedPipe pipe;

  if (pipe.openExisting("juce demo pipe"))  
  {
    const String text("Test_pipe");
    MemoryBlock messageData (text.toUTF8(), text.getNumBytesAsUTF8());
    pipe.write(messageData.getData(), messageData.getSize());
    pipe.close();
  }
}

This will also hang the JuceDemo after being called.

It works with a simple InterprocessConnection Object:

class IPCTest : public InterprocessConnection
{
public:

  IPCTest()
  {
    if (connectToPipe("juce demo pipe", -1))
    {
      const String text("Test_IPC");
      MemoryBlock messageData (text.toUTF8(), text.getNumBytesAsUTF8());
      sendMessage(messageData);
      disconnect();
    }
  }

  void messageReceived(const MemoryBlock& message) {}
  void connectionLost() {}
  void connectionMade() {}
};

When I create an IPCTest object, the message gets sent to the JuceDemo.

In the end I’d like to send data from a command line application. I ran into an assertion when trying to create an IPCTest object in a non-GUI application; I suppose the InterprocessConnection needs a message thread.

Am I doing something wrong with the NamedPipe object or is there any other way to connect from a command line app to another process?

Thanks,
Chris


#2

Sounds like it should work… If you’re using windows, have you seen dbyron’s posts about problems he’s been having with it?


#3

Yes this is Windows, i forgot to mention; didn’t test on OS X.

I had a look at dbyron’s posts but as far as I understand from reading over them they are all connected to InterprocessConnection.
I’d like to avoid a callback for reading from the command line app so something like a sinlge StreamingSocket or NamedPipe object seems to be the way for me to go.
On the other hand the other side of the communication uses an InterprocessConnection atm. Could the combination of NamedPipe/StreamingSocket (which I didn’t get to connect either) and InterprocessConnection be the reason for the failing connection/crash?

Thanks,
Chris


#4

Ok, I’m really not sure off-hand and haven’t got time to dig into this and figure it out right now… I’ll have more time to investigate in a few days, so nag me again then if I forget to look at it.