Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > main > by-pkgid > 0afeee9cca140e167a996902b9a677c5 > files > 2451

php-manual-en-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>shmop_open</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="Shared Memory Functions"
HREF="ref.shmop.html"><LINK
REL="PREVIOUS"
TITLE="shmop_delete"
HREF="function.shmop-delete.html"><LINK
REL="NEXT"
TITLE="shmop_read"
HREF="function.shmop-read.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.shmop-delete.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.shmop-read.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.shmop-open"
></A
>shmop_open</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN84903"
></A
><P
>    (PHP 4 &#62;= 4.0.4)</P
>shmop_open&nbsp;--&nbsp;Create or open shared memory block</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN84906"
></A
><H2
>Description</H2
>int <B
CLASS="methodname"
>shmop_open</B
> ( int key, string flags, int mode, int size)<BR
></BR
><P
>&#13;     <B
CLASS="function"
>shmop_open()</B
> can create or open a shared memory block.
    </P
><P
>&#13;     <B
CLASS="function"
>shmop_open()</B
> takes 4 parameters: key, which is the
     system's id for the shared memory block, this parameter can be passed
     as a decimal or hex. The second parameter are the flags that you can use:
     <P
></P
><UL
><LI
><P
>&#13;        "a" for access (sets SHM_RDONLY for shmat)
        use this flag when you need to open an existing shared memory segment for read only
       </P
></LI
><LI
><P
>&#13;        "c" for create (sets IPC_CREATE)
        use this flag when you need to create a new shared memory segment or if a
	segment with the same key exists, try to open it for read and write
       </P
></LI
><LI
><P
>&#13;        "w" for read &#38; write access
	use this flag when you need to read and write to a shared memory segment, use this flag
	in most cases.
       </P
></LI
><LI
><P
>&#13;        "n" create a new memory segment (sets IPC_CREATE|IPC_EXCL)
	use this flag when you want to create a new shared memory segment but if one
	already exists with the same flag, fail. This is useful for security purposes, using this you
	can prevent race condition exploits.
       </P
></LI
></UL
>
     The third parameter is the mode, which are the permissions that you
     wish to assign to your memory segment, those are the same as permission
     for a file. Permissions need to be passed in octal form ex. 0644.
     The last parameter is size of the shared memory block you wish to create
     in bytes.
     <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
      Note: the 3rd and 4th should be entered as 0 if you are opening an
      existing memory segment. On success <B
CLASS="function"
>shmop_open()</B
> will
      return an id that you can use to access the shared memory segment
      you've created.
     </P
></BLOCKQUOTE
></DIV
>
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN84940"
></A
><P
><B
>Example 1. Create a new shared memory block</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>&#60;?php
$shm_id = shmop_open(0x0fff, "c", 0644, 100);
?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     This example opened a shared memory block with a system id of 0x0fff.
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.shmop-delete.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.shmop-read.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>shmop_delete</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.shmop.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>shmop_read</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>