xref: /PHP-5.5/ext/shmop/README (revision 02e4d7a2)
1last update Jan 2, 2002 (hackie@prohost.org/ilia@prohost.org)
2
3Shared Memory Operations Extension to PHP
4
5	While developing a search deamon we needed a php based front end
6	to communicate the deamon via SHM. PHP already had a shared memory
7	extension (sysvshm) written by Christian Cartus <cartus@atrior.de>,
8	unfortunately this extension was designed with PHP only in mind and
9	offers high level features which are extremly bothersome for basic SHM
10	we had in mind.  After spending a day trying to reverse engineer and figure
11	out the format of sysvshm we decided that it would be much easier to
12	add our own extension to php for simple SHM operations, we were right :)).
13
14the functions are:
15
16int shmop_open(int key, string flags, int mode, int size)
17
18	key 		- the key of/for the shared memory block
19	flags 		- 4 flags are avalible
20				a for read only access (sets SHM_RDONLY)
21				w for read & write access
22				c create or open an existing segment (sets IPC_CREATE)
23				n create a new segment and fail if one already exists under same name (sets IPC_CREATE|IPC_EXCL)
24				(the n flag is mostly useful for security perpouses, so that you don't end up opening a faked segment
25				if someone guesses your key)
26	mode		- acsess mode same as for a file (0644) for example
27	size		- size of the block in bytes
28
29	returns an indentifier
30
31
32char shmop_read(int shmid, int start, int count)
33
34	shmid		- shmid from which to read
35	start		- offset from which to start reading
36	count		- how many bytes to read
37
38	returns the data read
39
40int shmop_write(int shmid, string data, int offset)
41
42	shmid		- shmid from which to read
43	data		- string to put into shared memory
44	offset		- offset in shm to write from
45
46	returns bytes written
47
48int shmop_size(int shmid)
49
50	shmid 		- shmid for which to return the size
51
52	returns the size in bytes of the shm segment
53
54
55int shmop_delete(int shmid)
56
57	marks the segment for deletion, the segment will be deleted when all processes mapping it will detach
58
59	shmid		- shmid which to mark for deletion
60
61	returns 1 if all ok, zero on failure
62
63int shmop_close(int shmid)
64
65	shmid 		- shmid which to close
66
67	returns zero
68
69
70