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

In summary, the conversation discusses the need for fast inter-process communication between a 64-bit and a 32-bit Windows Visual C++ program. Possible solutions such as using the Windows clipboard, a simple file, or a memory-mapped file are mentioned. The use of semaphore and mutexes to synchronize access between tasks is also suggested. Other suggestions include using the boost interprocess library or creating a Ramdisk. Ultimately, the individual ended up using a simple file on the disk for communication, which provided sufficient speed and no permission errors.
  • #1
chickenwing71
42
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
  • #2
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).
 
  • #3
The boost libraries (boost.org) include interprocess library that you might find useful. I haven't tried using it myself.
 
  • #4
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.
 
  • #5
a memory-mapped file might work, where one program writes to it, and the other reads from it
 
  • #6
Have you tried creating a Ramdisk?
 
  • #7
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!
 

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

1. What is IPC?

IPC stands for Interprocess Communication, which refers to the methods and mechanisms that allow different processes to communicate with each other and share data.

2. Why is IPC important for Windows C++ applications?

Windows C++ applications are typically standalone programs that run in their own processes. IPC allows these applications to communicate and exchange data, enabling them to work together and perform more complex tasks.

3. What are the different forms of IPC available for Windows C++ applications?

There are several forms of IPC available for Windows C++ applications, including shared memory, pipes, sockets, and remote procedure calls (RPC). Each form has its own advantages and disadvantages, so the best choice depends on the specific needs of the applications.

4. What is the best form of IPC for two Windows C++ applications?

The best form of IPC depends on the specific requirements and characteristics of the two applications. For example, if the applications need to share large amounts of data, shared memory may be the best choice. If the applications are located on different machines, then sockets or RPC may be more suitable.

5. How can I determine which form of IPC is best for my two Windows C++ applications?

Determining the best form of IPC for your applications requires careful consideration of factors such as the data size, frequency of communication, and network environment. It may also be helpful to consult with other developers or conduct performance tests to determine the most efficient form of IPC for your specific scenario.

Similar threads

  • Programming and Computer Science
Replies
30
Views
4K
  • Computing and Technology
2
Replies
37
Views
5K
  • Programming and Computer Science
Replies
15
Views
1K
  • Computing and Technology
Replies
10
Views
8K
Replies
16
Views
2K
  • Programming and Computer Science
Replies
4
Views
15K
  • STEM Academic Advising
Replies
13
Views
2K
  • General Discussion
Replies
2
Views
3K
Back
Top