C/C++ What's the best form of IPC for two Windows C++ applications?

Click For Summary
SUMMARY

The discussion centers on inter-process communication (IPC) between two Windows Visual C++ applications, one 64-bit and the other 32-bit. The user requires a method to send two integers from the 64-bit application to the 32-bit application at a rate of several updates per second. The final solution implemented was a simple file-based approach, yielding satisfactory read/write rates of 30 Hz, despite exploring alternatives like memory-mapped files, sockets, and pipes. The user also mentioned the potential use of the Boost Interprocess library for IPC, although they did not test it.

PREREQUISITES
  • Understanding of Windows Visual C++ programming
  • Knowledge of inter-process communication methods
  • Familiarity with file handling and synchronization mechanisms like semaphores and mutexes
  • Basic concepts of memory management in Windows applications
NEXT STEPS
  • Research the Boost Interprocess library for IPC solutions
  • Explore memory-mapped files for efficient data sharing between processes
  • Learn about Windows sockets for network-based IPC
  • Investigate the use of pipes for inter-process communication in Windows
USEFUL FOR

Windows C++ developers, software engineers working on IPC solutions, and anyone looking to optimize communication between applications in a mixed 32/64-bit environment.

chickenwing71
Messages
41
Reaction score
0
I have two Windows Visual C++ programs that need fast inter-process communication. One is limited to 64-bit because it depends on 8 gigs of ram, and the other is limited to 32-bit because it depends on a proprietary 32-bit .dll

I need to send basically two integers from the 64-bit application to the 32-bit, and update a few times per second. Purely one-way communication.

Would opening the windows clipboard for writing in one process and reading in another work? What about just a simple file? Or would I run into file locking errors? Any better suggestions? I don't want to go and learn some new library or api unless it's absolutely necessary. Thoughts?
 
Technology news on Phys.org
You can use semaphore and/or mutexes to sychronize access between tasks, but sharing handles to objects between tasks is an issue. The issue is passing an handle addresses for duplicatehandle() between tasks. One method is for the first task to allocate handles, and pass it's process id and handle addresses as command line parameters when invoking the second task. Using windows debugger functions it's possible for one task to read or write the memory of a second task, something commonly done by "trainers" for computer games. I've written some mult-threaded (shared memory space) apps, but not a multi-tasking (not shared memory space) app. A .dll has it's own memory space as well as access to the memory space of the calling task (I haven't tried this either).
 
The boost libraries (boost.org) include interprocess library that you might find useful. I haven't tried using it myself.
 
I haven't checked out boost, so can't comment on that. If that doesn't pan out I'd try a memory-mapped file.
 
a memory-mapped file might work, where one program writes to it, and the other reads from it
 
Have you tried creating a Ramdisk?
 
Thanks for all the suggestions! I ended up making a simple file on the disk to write/read from. It's definitely not ideal, and sockets, or pipes or some of the other solutions seem faster, but I'm still getting read/write rates of 30 Hz (even when combined with frequent log file writes), which is more than enough for my application. No permission errors either. I just took the easy way out, and it is more than fast enough for my application.

Thanks!
 

Similar threads

  • · Replies 30 ·
2
Replies
30
Views
6K
  • · Replies 37 ·
2
Replies
37
Views
7K
Replies
5
Views
14K
Replies
5
Views
2K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
16K
  • · Replies 58 ·
2
Replies
58
Views
5K
  • · Replies 10 ·
Replies
10
Views
11K