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

Click For Summary

Discussion Overview

The discussion centers on finding an effective method for inter-process communication (IPC) between two Windows C++ applications, one 64-bit and the other 32-bit. The focus is on achieving fast, one-way communication to send two integers from the 64-bit application to the 32-bit application, with updates occurring several times per second.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant suggests using the Windows clipboard for writing in one process and reading in another, questioning the feasibility of this approach.
  • Another participant proposes using a simple file for communication, raising concerns about potential file locking errors.
  • Synchronization methods such as semaphores and mutexes are mentioned as ways to manage access between tasks, though challenges with sharing handles across processes are noted.
  • A participant mentions the possibility of using the Boost interprocess library, although they have not personally tried it.
  • Memory-mapped files are suggested as a viable option for communication, with one participant indicating that one program could write to it while the other reads from it.
  • Creating a Ramdisk is proposed as an alternative method for IPC.
  • A later reply indicates that the original poster opted for a simple file solution, achieving satisfactory read/write rates despite acknowledging that other methods might be faster.
  • A link to MSDN documentation is provided for further reference, though no specific details are discussed.

Areas of Agreement / Disagreement

Participants express various suggestions and methods for IPC, but no consensus is reached on the best approach. Multiple competing views remain regarding the most effective IPC method.

Contextual Notes

Some participants highlight limitations and potential issues with certain methods, such as handle sharing and file locking, but these remain unresolved within the discussion.

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
7K
  • · 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