Thread: How to communicate between two processes

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Yes, in that select really shouldn't be in the struct in the first place, since it's not part of the actual address book data. Pass an int. (In this case, "pass" means "put in the first part of shared memory" I would guess. Hooray for re-developing the idea of a stack!)

  2. #17
    Registered User
    Join Date
    Sep 2011
    I did not get it. How to put it in the first part of shared memory.

  3. #18
    Registered User
    Join Date
    Nov 2010
    Long Beach, CA
    The shared memory is just a big chunk of memory both processes can write to, like a piece of paper shared between two people. Both people need to know what is on each line of the paper. You start by putting select on "the first line", or right at the beginning of the block of shared memory. Your array a will start on "the second line". In your code, shared_memory, which is the value returned by shmat(), is the starting address of your block of shared memory. For example:
    memcpy(shared_memory, &select, sizeof(select));  // store select at the beginning of shared_memory
    memcpy(shared_memory + sizeof(select), a, sizeof(a));  // store a at the first spot after select

  4. #19
    Registered User
    Join Date
    Sep 2011
    @tabstop and @anduril462. Thank you guys. Now my doubt is cleared.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to communicate with the web server
    By nadeem athani in forum Linux Programming
    Replies: 1
    Last Post: 03-09-2011, 09:11 AM
  2. Get .cpp and .h files to communicate...
    By yaya in forum C++ Programming
    Replies: 6
    Last Post: 11-25-2008, 12:45 AM
  3. How to communicate with com port?
    By alan85 in forum C++ Programming
    Replies: 7
    Last Post: 12-10-2004, 10:56 PM
  4. Getting two programs to communicate
    By Thantos in forum Windows Programming
    Replies: 4
    Last Post: 08-27-2003, 07:39 AM
  5. can't get MFC to communicate with itself
    By drb2k2 in forum C++ Programming
    Replies: 2
    Last Post: 04-04-2003, 04:06 PM

Tags for this Thread