Thread: Need advice regarding inter-process communication.

  1. #1
    Registered User
    Join Date
    May 2013
    Posts
    228

    Need advice regarding inter-process communication.

    This post is not a C related question per se, but nevertheless, I will be writing my code in C so I thought it will be appropriate. If it is not, please accept my apology and transfer it to wherever it belongs.

    I need an advice on some project I'm working on.
    I'm currently writing a C module that supposed to transfer data to another process (probably its parent process).
    The data should travel from my process to the other as fast and as reliably as possible. The data will be travelling in a burst manner, meaning every now and then it'll fire some data, where every burst won't be bigger than 1.5Mb in the (really) worst case (in practice it will be much less, no more than couple of KB, I reckon).

    The options I'm considering right now are:

    1. File - but that seems like too much overhead, plus I don't really like the idea of using files for IPC.
    2. Shared memory - this will require some synchronization mechanism, and that sounds too much effort, and too much headache for such a small transfer of data.
    3. Using a pipe of some sort (either named pipe or parent-child pipe) - I'm tending towards this option right now.
    4. Using a socket - but I'm not sure how common is it to use sockets for IPC, I also never tried to do it before with C, and I don't know how much noticeable overhead does using a socket for this purpose produce, if any.

    One last thing, and maybe I should have started with it, the program to which I'm sending the data might be written in Java. Does this place anymore obstacles I'm not aware of?

    Any help would be greatly appreciated.
    Last edited by Absurd; 04-27-2015 at 01:43 PM.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    What platform (Windows, Linux, etc) are you running on? Is it all on one machine, or are there multiple computers involved?
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #3

  4. #4
    Registered User
    Join Date
    Sep 2014
    Posts
    364
    I also work on an great project with one master process that fork a couple of childs.
    The synchronisation works over MSQ (massage-queue) and the transfer of data goes over SHM (shared memory).
    This was comletely new for me as I wrote the code, but its nice an work very fast.
    My program runs on Linux and work is in procress.
    I recommend you to read over IPC-SEM (semaphore), IPC-MSQ (massage-queue) and IPC-SHM (shared memory).
    It's really fast.
    Other have classes, we are class

  5. #5
    Registered User
    Join Date
    May 2013
    Posts
    228
    Quote Originally Posted by Elkvis View Post
    What platform (Windows, Linux, etc) are you running on? Is it all on one machine, or are there multiple computers involved?
    I'm using Linux platform, and only one machine is involved.

    Some more things I'm wondering about:
    It looks like the other process is almost definitely going to be written in Java.
    This makes the use of pipes a bit trickier, since to my best understanding, Java does not support pipes, and I'll have to use the JNI. :\
    On the other hand, socket now looks better, as both C and Java have good interface for that.

    Thanks for your comments.

  6. #6
    Registered User
    Join Date
    May 2013
    Posts
    228
    Quote Originally Posted by Codeplug View Post
    You could use something like zeromq: Code Connected - zeromq

    gg
    This looks interesting.
    I'll read more and comment back.

  7. #7
    Registered User
    Join Date
    May 2013
    Posts
    228
    Quote Originally Posted by WoodSTokk View Post
    I also work on an great project with one master process that fork a couple of childs.
    The synchronisation works over MSQ (massage-queue) and the transfer of data goes over SHM (shared memory).
    This was comletely new for me as I wrote the code, but its nice an work very fast.
    My program runs on Linux and work is in procress.
    I recommend you to read over IPC-SEM (semaphore), IPC-MSQ (massage-queue) and IPC-SHM (shared memory).
    It's really fast.
    Since the other process will be written in Java, it must use the JNI for that, and I'd prefer to avoid it for now, until I'll be convinced that there's no better option.

  8. #8

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inter process communication
    By Amitesh93 in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-02-2014, 07:07 AM
  2. Advice on inter-process communication
    By erupter in forum C Programming
    Replies: 8
    Last Post: 08-10-2012, 01:31 PM
  3. C program for Inter Process communication ( Tx and RX)
    By hiharsh in forum C Programming
    Replies: 3
    Last Post: 05-03-2007, 10:23 AM
  4. Inter program communication!!
    By visham in forum C Programming
    Replies: 16
    Last Post: 09-09-2005, 12:02 AM
  5. Inter-Process Communication in Windows
    By JBravo in forum C++ Programming
    Replies: 3
    Last Post: 03-11-2002, 10:55 AM