By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,357 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

Shared memory between scripts ? shmop etc... help !

P: n/a
Hi,
I am trying to develop a very basic but portable chat engine with php.
I would like to develop it without any database or filesystem stuff,
because I want it very portable and easy to install. So I was looking
for a way to make scripts communicate, or keep a kind of state . So
someone told me to look for shared memory operations... shmop_open and
all this things.... but I cant seem to find a script that uses this,
or something that works...
I tried some examples (always same ones) on different phpsites, like
creating a shmop object, writing on it then reading from it, all in
the same script... what i would like to do is slightly different; have
a writer page, and a reader page, then i could do some kind of chat
..... the writer page would be the textsubmitter stuff... the reader
page would be an autoreloading page ... then with some simple
parameters I could finalize a very simple chat, pluggable anywhere ...
so ... When I do a write page, it works, but when I try to read, on
another script, with for example this:

<?
$shm_id = shmop_open(0xff3, "a", 0644, 100);
echo $shm_id;
?>
0xff3 being the place where i created on the wrietr page ... then i
get:
Warning: shmop_open(): unable to attach or create shared memory
segment in /var/www/localhost/htdocs/chat/read.php on line 2

So I dont understand why it doesn't work !

Thanks for your attention
Patricio Stegmann
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Patricio Stegmann wrote:
another script, with for example this:

<?
$shm_id = shmop_open(0xff3, "a", 0644, 100);
echo $shm_id;
?>
0xff3 being the place where i created on the wrietr page ... then i
get:
Warning: shmop_open(): unable to attach or create shared memory
segment in /var/www/localhost/htdocs/chat/read.php on line 2


I'd recommend only every (re) creating the key using ftok(). But why are you
bothering with shm at all? If you control both ends of the system on a
Unix/Linux box there's very little overhead in using a real file.

HTH

C.
Jul 17 '05 #2

P: n/a
"Patricio Stegmann" <kp****@hotmail.com> wrote in message
news:18**************************@posting.google.c om...
Hi,
I am trying to develop a very basic but portable chat engine with php.
I would like to develop it without any database or filesystem stuff,
because I want it very portable and easy to install. So I was looking
for a way to make scripts communicate, or keep a kind of state . So
someone told me to look for shared memory operations... shmop_open and
all this things.... but I cant seem to find a script that uses this,
or something that works...
I tried some examples (always same ones) on different phpsites, like
creating a shmop object, writing on it then reading from it, all in
the same script... what i would like to do is slightly different; have
a writer page, and a reader page, then i could do some kind of chat
.... the writer page would be the textsubmitter stuff... the reader
page would be an autoreloading page ... then with some simple
parameters I could finalize a very simple chat, pluggable anywhere ...
so ... When I do a write page, it works, but when I try to read, on
another script, with for example this:

<?
$shm_id = shmop_open(0xff3, "a", 0644, 100);
echo $shm_id;
?>
0xff3 being the place where i created on the wrietr page ... then i
get:
Warning: shmop_open(): unable to attach or create shared memory
segment in /var/www/localhost/htdocs/chat/read.php on line 2

So I dont understand why it doesn't work !


Resources are freed automatically when a script terminates, duh!
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.