README 2.1 KB

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