You are here: Shared memory between 2 processes??? « PHP Programming Language « IT news, forums, messages
Shared memory between 2 processes???

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация