|
Posted by Tamagafk on 11/29/06 11:21
Hi,
I have two running php processes (they have infinite loops) and I need
them to pass some data to eachother. Writing and reading shared memory
in one process works just fine but when I try to save var in process1
and read in process2 I get error: "Variable key 555 doesn't exist".
What I'm doing wrong?
Here are the sources:
//PROCESS 1 (saving var)
$key = 'My Key';
$value = 'My Value';
$app = 'lovelyapp';
$key = $key . 'a';
$segment_key = abs(crc32($app . $key));
$segment_size = 1024;
$segment_perms = 0600;
$shm_id = shm_attach($segment_key, $segment_size, $segment_perms);
shm_put_var($shm_id, 555, $value);
shm_detach($shm_id);
// PROCESS 2 (reading var)
$key = 'My Key';
$app = 'lovelyapp';
$key = $key . 'a';
$segment_key = abs(crc32($app . $key));
$segment_size = 1024;
$segment_perms = 0600;
$shm_id = shm_attach($segment_key, $segment_size, $segment_perms);
$value = shm_get_var($shm_id, 555);
shm_detach($shm_id);
Thnaks!
Navigation:
[Reply to this message]
|