Yeah, it's cool so far. I've built up a chat system with Shm/Sem. It goes like this:
Lock memory so no collisions occur (funny effects in a chat)
$shm_addr must be diffrent for every Script willing to use a diffrent memory
$shm_addr = 1;
$sem_id = sem_get($shm_addr);
sem_acquire($sem_id);
That about semaphores
Now to the real shared mem:
$shmid = shm_attach($shm_addr, $shm_size);
$alldata = shm_get_var($shmid, 1);
shm_detach($shmid);
There you got a var "$alldata" out of shm
Same procedure for writing
$shmid = shm_attach($shm_addr, $shm_size);
shm_put_var($shmid, 1, $alldata);
shm_detach($shmid);
After reading and writing, release the semaphore so the memory is shared
sem_release($sem_id);
So far it works really good. We had about 30 users in one chatroom and nothing went wrong. Really cool.
Dean wrote:
I am trying to do something with shared memory as well. I'm new to PHP, so I'm unsure of what it's capabilities are. Have you come across anything thus far?
Thanks for any advice,
Dean