C or C++ library for inter-process communication in Windows

So I’m doing development work on Windows, and I’d like to do some communication between two processes running on the same machine (but not in the same user session, potentially). Seems to me there are about 4 different ways I can do that:
-shared memory
-a named pipe
-memory-mapped files

What I really want is a client-server model, where one running program can say “OK, I’m listening here on a named-or-numbered channel of some sort” and other programs can connect and disconnect, and while they’re connected, they can pass streams of bytes back and forth".

None of those methods seem dauntingly difficult, but I feel like setting up a nice robust module is going to involve a bunch of work to get all the corner cases and synchronization and so forth working properly, and this seems like a problem that someone else must have already solved.

So… is the a library or package I can find somewhere that does all the dirty work and presents a nice clean usable API?

You could use sockets, here’s a link to a C tutorial:

I’ve done exactly what you are looking to do but in Java, worked well.

We already have a very robust socket library which we use for TCP/IP communication between programs running on different machines. What we do not have (and what I suspect must be possible) is a similar system which takes advantage of knowing that the communicating processes are running on the machine and can thus avoid a bunch of overhead and run much faster.

Just took a look there. That tutorial says explicitly that it’s for Linux ONLY, and not for Winders. But, depending on what level of beginnerness the OP is looking for, it could be a good conceptual lesson in any case.

Are you talking strictly synchronous communication? If not, what about using an open source messaging system like ActiveMQ?


Write to a queue from one process, read from it from another, all the robustness is built-in for you. Only problem is it might be a bit heavyweight for your purposes. Or, it could provide a lot of functionality you might find useful (store and forward, etc.)

Actually, you can do synchronous with it too, I think it just takes a bit more work.

ETA: I know you said C/C++ but I’m sure there’s a a C/C++ client for it.

Yeah… flexibility is unimportant here, this is all programs written in C/C++ with the same libraries linked in all running on a single Windows machine. What’s important is performance, so that a program that runs for only a fraction of a second can connect, send some data, and disconnect, without tons of overhead.

Ok, then what about these guys? Never used it before, but sounds promising:


Missed edit window.

Better link with sample code: http://www.boost.org/doc/libs/1_55_0/doc/html/interprocess/sharedmemorybetweenprocesses.html

Yeah, shared memory definitely seems like the right approach, but there’s a LOT of extra work involved in getting all the details right. This seems to be a learned discussion of the topic.

But so far I haven’t actually found a library that does what I need.


Well it might be based on one of the earlier 4 but being somewhat inbuilt (not a third party library), and being easier to use,… well it might be what the OP wanted.