Best way to exchange stuff via IPC ?

Hi All,

IPC is very cute but you have to devise a “protocol” if you want to exchange more than a couple of static text strings.

Instead of reinventing the wheel I’m trying JSONItem - It is structured, can be sent over the socket as a whole string and then converted back to JSONItem and you can lookup() and etc.

However when a few processes rapidly (once a second) send things to each other sometimes IPC messages seem to get corrupt. Maybe sort of a race condition, whose data is processes by DataAvailable first, not sure yet. Perhaps will need to add some sort of a CRC as part of a JSONItem values, to see if anything’s been corrupted.

Anybody know of a better way?

Cheers!

DataAvailable means SOME data has been received
Its NOT a “hey the entire thing that was sent has arrived” because IPC / UDP etc dont know that
They are transport layers which means “we get chunks of data from here to there” with varying assurances - TCP guarantees packets are received in order and they are resent if they do not arrive etc

The protocols (http etc) define HOW to recognize a complete message

@Norman so is there an equivalent to that in IPC or it has to be implemented on top of “raw” IPC?

thanks!

IPC is just another transport mechanism like TCP & UDP
You need some kind of protocol on top of it to know when a full message has arrived

But thats not hard
Send 4 NULLS (chrb(0)) before the JSON, send the json then four chrb(1)'s (ie a begin tag and an end tag) or something
On the receiving end just look for those framing bytes and anything in between is your “message”
Just buffer things up until you have a 0000 1111 basically then use the data

It doesn’t have to be overly complex

Cool, so perhaps need to break a message into numbered chunks and let the receiver reassemble it as chunks arrive. Suggestions welcome…

Perhaps Xojo could make something standard here?