here's the deal...
i need two applications that i need to communicate through a shared memory segment...
lets say the user starts program A, i need it to create a shared memory segment and a semaphore,
when the user stats program B, i need it to attach itself to the segment and the semaphore.
i also need it to work the other way around, i cant tell which of the applications the users will start first.
i tried using a key for the semphore and the segment but i couldn't get it to work...
in both applications this is how i init the shared memory segment and the semaphore:
Code:
shmid = shmget(skey, SEGMENT_SIZE, IPC_CREAT | 0666);
buffer = (char *) shmat(shmid, NULL, 0);
semid = semget(skey,1,IPC_CREAT | 0666);
semctl(semid, 0, SETALL, 0);
who do i set the properties that will create a segment if there isnt an segment exist with the key, if the segment exists i want to get the segment id so i could attach to it, same goes for the semaphore...
i cant figure it out from the man pages.......
thanks kin advance for your help...