Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Jun 15, 2010 #1
    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?
  2. jcsd
  3. Jun 15, 2010 #2


    User Avatar
    Homework Helper

    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).
  4. Jun 15, 2010 #3


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    The boost libraries (boost.org) include interprocess library that you might find useful. I haven't tried using it myself.
  5. Jun 17, 2010 #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.
  6. Jun 21, 2010 #5


    User Avatar
    Gold Member

    a memory-mapped file might work, where one program writes to it, and the other reads from it
  7. Jun 22, 2010 #6
    Have you tried creating a Ramdisk?
  8. Jun 28, 2010 #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.

  9. Jun 28, 2010 #8


    User Avatar

    Staff: Mentor

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook