(Off Topic) Recommendations for messaging between processes?

Hello, I have been writing a game engine for to teach myself about SDL
for quite a while now. The engine has reached a level of complexity
that I feel it would be beneficial to have a external debugging
program to aid in development. More precisely I would like to be able
to pause/unpause the game and track objects [and their variables]
without too much extra coding effort.

I’ll probably be writing the debugging application in python, but
thats not terribly relevant to the question. My question is how should
implement inter-process communications ? What libraries could I use to
achieve communication in-between two programs quickly and painlessly ?
(SDL_Net, Sockets, D-Bus, etc …) Development is almost exclusively
on Linux so I don’t care if it would break cross platform
compatibility.

If anyone has some words of wisdom it would be greatly appreciated.–
Jason White

For messaging format, you should look up Protocol Buffers. (
https://developers.google.com/protocol-buffers/ ) Really nicely
designed, you write out a simple spec which describes the structure of
the message, which is then compiled to a nice class-based interface
for your target language (e.g. C++, Python). Just the sauce for
serializing lots of tricky data.

As for the actual IPC part, there’s many different ways to go about it
(pipes, sockets, shared memory segments). I haven’t tried writing an
IPC layer, so the best advice I have is to hit up Stack Overflow and
flip through until you find something which gels with your instincts
about how things should work. Or try out one of the prebaked IPC
libraries based on Protobuf (
http://code.google.com/p/protobuf/wiki/ThirdPartyAddOns ), or dig
through the source code of a project which has rolled their own
solution (e.g. Clementine music player uses Protobuf for IPC).On Wed, May 16, 2012 at 8:56 AM, Jason White wrote:

Hello, I have been writing a game engine for to teach myself about SDL
for quite a while now. The engine has reached a level of complexity
that I feel it would be beneficial to have a external debugging
program to aid in development. More precisely I would like to be able
to pause/unpause the game and track objects [and their variables]
without too much extra coding effort.

I’ll probably be writing the debugging application in python, but
thats not terribly relevant to the question. My question is how should
implement inter-process communications ? What libraries could I use to
achieve communication in-between two programs quickly and painlessly ?
(SDL_Net, Sockets, D-Bus, etc …) Development is almost exclusively
on Linux so I don’t care if it would break cross platform
compatibility.

If anyone has some words of wisdom it would be greatly appreciated.


Jason White


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Check ZeroMQ and CrossRoads-IO (fork of ZeroMQ).
For serializing there is MessagePackOn 5/15/2012 5:56 PM, Jason White wrote:

Hello, I have been writing a game engine for to teach myself about SDL
for quite a while now. The engine has reached a level of complexity
that I feel it would be beneficial to have a external debugging
program to aid in development. More precisely I would like to be able
to pause/unpause the game and track objects [and their variables]
without too much extra coding effort.

I’ll probably be writing the debugging application in python, but
thats not terribly relevant to the question. My question is how should
implement inter-process communications ? What libraries could I use to
achieve communication in-between two programs quickly and painlessly ?
(SDL_Net, Sockets, D-Bus, etc …) Development is almost exclusively
on Linux so I don’t care if it would break cross platform
compatibility.

If anyone has some words of wisdom it would be greatly appreciated.

How about UNIX named pipes?

// Receiver (run first)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
int main(void) {
FILE *npfp; char input[80];
mknod(“myPipe”,S_IFIFO|0666,0);
for(;:wink: {
npfp=fopen(“myPipe”,“r”);
fgets(input,80,npfp);
printf(“Got string: %s\n”,input);
fclose(npfp);
}}

// Sender (run to send)
#include <stdio.h>
#include <stdlib.h>
int sender_main(void) {
FILE *npfp;
if((npfp=fopen(“myPipe”,“w”))==NULL) return 1;
fputs(“Data”,npfp);
fclose(npfp);
return 0;
}On 5/15/2012 5:56 PM, Jason White wrote:

Hello, I have been writing a game engine for to teach myself about SDL
for quite a while now. The engine has reached a level of complexity
that I feel it would be beneficial to have a external debugging
program to aid in development. More precisely I would like to be able
to pause/unpause the game and track objects [and their variables]
without too much extra coding effort.

I’ll probably be writing the debugging application in python, but
thats not terribly relevant to the question. My question is how should
implement inter-process communications ? What libraries could I use to
achieve communication in-between two programs quickly and painlessly ?
(SDL_Net, Sockets, D-Bus, etc …) Development is almost exclusively
on Linux so I don’t care if it would break cross platform
compatibility.

If anyone has some words of wisdom it would be greatly appreciated.

[…]

I’ll probably be writing the debugging application in python, but
thats not terribly relevant to the question. My question is how should
implement inter-process communications ? What libraries could I use to
achieve communication in-between two programs quickly and painlessly ?
(SDL_Net, Sockets, D-Bus, etc …) Development is almost exclusively
on Linux so I don’t care if it would break cross platform
compatibility.

I’ve been doing a bit of that stuff with embedded systems (lab instrumenst),
using TCP/IP via SDL_net and NET2. Communication with the Windows GUI was done
using the same basic protocol anyway, so it was handy to just build on that.
The instrument would act as a server, allowing one or more clients to connect
to it, upload scripts etc. (That was actually the protocol; send a script
over, talking to the local server APIs, sending back whatever the client
needed.)

I wanted the tools to run “everywhere” (my Linux devsystems and the Windows
boxes in the lab), so they’re all written in EEL (custom scripting engine that
I originally designed for the purpose of doing 1+ kHz realtime scripting on
those instruments), and of course, SDL and TCP/IP is available on pretty much
anything.

Also, since NET2 provides an event based API, it’s easy to deal with
asynchronous communication without dealing with thread synchronization issues
all over the place.

On those instruments, I also made send operations guaranteed non-blocking by
means of lock-free FIFOs (I think that’s actually still in EELBox…), but
that’s probably overkill unless you’re doing something critical on a proper
realtime OS.On Wednesday 16 May 2012, at 02.56.08, Jason White wrote:


//David Olofson - Consultant, Developer, Artist, Open Source Advocate

.— Games, examples, libraries, scripting, sound, music, graphics —.
| http://consulting.olofson.net http://olofsonarcade.com |
’---------------------------------------------------------------------’