IPC Puzzle

Greetings -

I am trying to set up an IPC channel between a master and a slave.

The slave is started first, then the master. The connection appears to be properly established. The slave is told to listen. The master sends “TEST”, and immediately switches to listen, and the slave receives the message, but very quickly detects a disconnect (ERROR 102 = Lost Connection). The master does not detect the Lost Connection. As far as I can tell, the switch to listen happens well before any action is taken by the slave other than that the slave reads the available data. It does not write anything for 100ms.

If the master does not switch to listen, the slave detects an ERROR 22, which is not on the IPC error list.

If the master does no write, no error occurs in the slave.

Does anyone have any insight about what might be going on or what error code 22 refers to?

Many thanks
Jim Wagner
Oregon Research Electronics

Only one needs to listen the other tries to connect and once you do you’re good to go.
They are connected over a bidirectional socket so once they connect why would you tell the “slave” to “listen”.
That’s sure to break the connection.
Simply read and write on either end when you need to and handle the incoming data.
Just don’t assume that “DataAvailable” means “There’s a whole message to process” as it could be complete or partial.

I think the included example does that (listen), but I am not exactly sure. I’ll try without that.

Guess I’ll add a message delimiter so that I can tell that a complete message is received. Thanks on that. There is no discussion of allowed characters or encodings. Is it correct to assume that the standard ASCII control characters are permitted?

So, does a participant in an IPC channel automatically listen when it is not writing?

Jim

I’m going to assume you’re on OS X. Error code 22 is a system error, coming from the BSD sockets that IPCSocket is implemented on top of. Unfortunately it just means EINVAL (Invalid argument), which is not too useful on its own.

Almost a year ago, I posted a comment in a thread thread on IPCSocket. It might contain some useful information.

Thanks, Joe -

I’ll check that out.

Jim

[quote=108291:@James Wagner]I think the included example does that (listen), but I am not exactly sure. I’ll try without that.

Guess I’ll add a message delimiter so that I can tell that a complete message is received. Thanks on that. There is no discussion of allowed characters or encodings. Is it correct to assume that the standard ASCII control characters are permitted?

So, does a participant in an IPC channel automatically listen when it is not writing?

Jim[/quote]
One side has to listen, and the other side has to connect.
But once you DO get a connection unless it drops or you close it there’s no need to switch one to listen again.
So when you say “The slave is started first, then the master. The connection appears to be properly established. The slave is told to listen. The master sends “TEST”, and immediately switches to listen
You don’t need to do this.
If the “master” ALWAYS listens for slaves to connect and the slaves simply retry connecting periodically until they do get a connection then you don’t have to do this business of the slave listening for the master connecting then switching things around so the master listens & the slave then tries to connect to it.

I completely misunderstood the function of Listen. Went back and read the LR, and now that is much more clear. And your explanation helped, also.

Thanks
Jim