473,379 Members | 1,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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

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
2 4002
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Porky Pig Jr | last post by:
Hello, I'm not that familiar with python, but in any case ... This is the academic project involving 'extensible systems', where routines are allocated in some memory shared among the multiple...
0
by: Srijit Kumar Bhadra | last post by:
Hello, Here is some sample code with pywin32 build 203 and ctypes 0.9.6. Best regards, /Srijit File: SharedMemCreate_Mutex_win32all.py # This application should be used with...
5
by: otiteca | last post by:
Hi, Is there anyway to share a variable between many web users ? I've got an array, updated by users's actions. i do want this same array be available to all web users in their sessions. ...
3
by: alanrn | last post by:
I would like to start a dialog on how to implement the equivalent functionality of UNIX shared memory in .NET. I work with a factory automation system. The bulk of the system is written in C/C++....
11
by: Michael Schuler | last post by:
The use of STL in shared memory poses a real problem since (non-smart) pointers are not allowed there. Is there any solution for containers in shared memory using smart pointers? Where can I...
12
by: Jeremy | last post by:
Hi all, I'm getting very confused about how DB2 uses shared memory and I wonder if someone could clarify matters for me, please ? We are running 32bit DB2 V7.2 FP9 under AIX 4.3.3 on a machine...
1
by: Jay | last post by:
Hey There, I am going to be having a bunch of files created from a mysql database, and then these files will be zipped together. While the files are being created, is it possible to store the...
3
by: Alexey Kulentsov | last post by:
Hi All! Is here any solution? APC and shm_ functions doesn't work from command line but I need it.
1
by: landacorp | last post by:
Hi, everyone! I am having trouble with values stored into the shared memory. Either i create "shmop_write" the value into the segment by cron and i being able to get it from the memory from...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.