File: msg-receive.xml

package info (click to toggle)
php-doc 20061001-1
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 45,764 kB
  • ctags: 1,611
  • sloc: xml: 502,485; php: 7,645; cpp: 500; makefile: 297; perl: 161; sh: 141; awk: 28
file content (135 lines) | stat: -rw-r--r-- 5,961 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
  <refentry id="function.msg-receive">
   <refnamediv>
    <refname>msg_receive</refname>
    <refpurpose>
     Receive a message from a message queue
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
    <methodsynopsis>
     <type>bool</type><methodname>msg_receive</methodname>
     <methodparam><type>resource</type><parameter>queue</parameter></methodparam>
     <methodparam><type>int</type><parameter>desiredmsgtype</parameter></methodparam>
     <methodparam><type>int</type><parameter role="reference">msgtype</parameter></methodparam>
     <methodparam><type>int</type><parameter>maxsize</parameter></methodparam>
     <methodparam><type>mixed</type><parameter role="reference">message</parameter></methodparam>
     <methodparam choice="opt"><type>bool</type><parameter>unserialize</parameter></methodparam>
     <methodparam choice="opt"><type>int</type><parameter>flags</parameter></methodparam>
     <methodparam choice="opt"><type>int</type><parameter role="reference">errorcode</parameter></methodparam>
    </methodsynopsis>
    <para>
     <function>msg_receive</function> will receive the first message from the
     specified <parameter>queue</parameter> of the type specified by
     <parameter>desiredmsgtype</parameter>.
     The type of the message that was received will be stored in
     <parameter>msgtype</parameter>.
     The maximum size of message to be accepted is specified by the
     <parameter>maxsize</parameter>; if the message in the queue is larger
     than this size the function will fail (unless you set
     <parameter>flags</parameter> as described below).
     The received message will be stored in <parameter>message</parameter>,
     unless there were errors receiving the message, in which case the
     optional <parameter>errorcode</parameter> will be set to the value of the
     system errno variable to help you identify the cause.
    </para>
    <para>
     If <parameter>desiredmsgtype</parameter> is 0, the message from the front
     of the queue is returned. If <parameter>desiredmsgtype</parameter> is
     greater than 0, then the first message of that type is returned.
     If <parameter>desiredmsgtype</parameter> is less than 0, the first
     message on the queue with the lowest type less than or equal to the
     absolute value of <parameter>desiredmsgtype</parameter> will be read.
     If no messages match the criteria, your script will wait until a suitable
     message arrives on the queue.  You can prevent the script from blocking
     by specifying <constant>MSG_IPC_NOWAIT</constant> in the 
     <parameter>flags</parameter> parameter.
    </para>
    <para>
     <parameter>unserialize</parameter> defaults to &true;; if it is set to
     &true;, the message is treated as though it was serialized using the same
     mechanism as the session module.  The message will be unserialized and
     then returned to your script.  This allows you to easily receive arrays
     or complex object structures from other PHP scripts, or if you are using
     the WDDX serializer, from any WDDX compatible source.
     If <parameter>unserialize</parameter> is &false;, the message will be
     returned as a binary-safe string.
    </para>
    <para>
     The optional <parameter>flags</parameter> allows you to pass flags to the
     low-level msgrcv system call.  It defaults to 0, but you may specify one
     or more of the following values (by adding or ORing them together).
     <table>
      <title>Flag values for msg_receive</title>
      <tgroup cols="2">
       <tbody>
        <row>
         <entry><constant>MSG_IPC_NOWAIT</constant></entry> 
         <entry>If there are no messages of the
          <parameter>desiredmsgtype</parameter>, return immediately and do not
          wait.  The function will fail and return an integer value
          corresponding to ENOMSG.
         </entry>
        </row>
        <row>
         <entry><constant>MSG_EXCEPT</constant></entry>
         <entry>Using this flag in combination with a
          <parameter>desiredmsgtype</parameter> greater than 0 will cause the
          function to receive the first message that is not equal to
          <parameter>desiredmsgtype</parameter>.</entry>
        </row>
        <row>
         <entry><constant>MSG_NOERROR</constant></entry> 
         <entry>
          If the message is longer than <parameter>maxsize</parameter>,
          setting this flag will truncate the message to
          <parameter>maxsize</parameter> and will not signal an error.
         </entry>
        </row>
       </tbody>
      </tgroup>
     </table>
    </para>
    <para>
     Upon successful completion the message queue data structure is updated as
     follows: <literal>msg_lrpid</literal> is set to the process-ID of the
     calling process, <literal>msg_qnum</literal> is decremented by 1 and
     <literal>msg_rtime</literal> is set to the current time.
    </para>
    <para>
     <function>msg_receive</function> returns &true; on success or &false; on
     failure.  If the function fails, the optional
     <parameter>errorcode</parameter> will be set to the value of the system
     errno variable.
    </para>
    <para>
     See also <function>msg_remove_queue</function>,
     <function>msg_send</function>,
     <function>msg_stat_queue</function> and
     <function>msg_set_queue</function>.
    </para>
   </refsect1>
  </refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->