Yet another IPC question

Ok, I read all the Resource Manager stuff and I spent the day getting some test code to work. One process creates the Resource Manager and another process fopen()s the ‘file’ and reads from it. I don’t think it meets my needs…

However, I really want the processes to send each other mesages the way we did in QNX way back in the '80s. I want one task to block waiting for a message and another task to send it messages of varying content and length. I don’t want to share memory either. I have a small set of specific messages, some with binary data, that must pass among the processes on an embedded system. I don’t see an obvious way to implement this with fgets() or even fread(). There must be a way to do something this simple but it’s not jumping out at me.


Cincinnati, OH USA

Sure… :slight_smile:

You can write the way you used to - with MsgSend(), MsgReceive() and MsgReply().

Or, if you already have it working, the following accomplishes the same thing:

open() - to establish a connection
write() - use it like MsgSend() to send data to the RM.
read() - use it like MsgSend() to get data from the RM.
close() - to close the connection and free resources.

Or perhap in more detail, write() is like sending data and getting an ACK back as the reply. Read is like sending a request and getting data back as the reply.

This is the way that open/read/write/close have always worked (in all versions of QNX). All that changed was the RM framework makes it easier to write the server.

If you chose to go with the familiar, you will need a way to “learn” the channel id from the server. Unlike previous versions of QNX, you need both a pid AND a channel id. With the pid/chid, you can create a connection and the coid (connection id) is used by MsgSend() to send a message.

You can use ConnectAttach(), open(), name_open() or some other method (pass them to a child as arguments) to create the connection.

Also coids are resources which you can leak - you need to make sure you “close” everyone you create - when you are finished with it of course. Think of it as a file descriptor (which is what it is). :slight_smile: