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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.11 $ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.msg-receive">
<refnamediv>
<refname>msg_receive</refname>
<refpurpose>Receive a message from a message queue</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<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>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>queue</parameter></term>
<listitem>
<para>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>desiredmsgtype</parameter></term>
<listitem>
<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>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>msgtype</parameter></term>
<listitem>
<para>
The type of the message that was received will be stored in this
parameter.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>maxsize</parameter></term>
<listitem>
<para>
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).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>message</parameter></term>
<listitem>
<para>
The received message will be stored in <parameter>message</parameter>,
unless there were errors receiving the message.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>unserialize</parameter></term>
<listitem>
<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.
</para>
<para>
If <parameter>unserialize</parameter> is &false;, the message will be
returned as a binary-safe string.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>flags</parameter></term>
<listitem>
<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 <constant>MSG_ENOMSG</constant>.
</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>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>errorcode</parameter></term>
<listitem>
<para>
If the function fails, the optional <parameter>errorcode</parameter>
will be set to the value of the system errno variable.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</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>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>msg_remove_queue</function></member>
<member><function>msg_send</function></member>
<member><function>msg_stat_queue</function></member>
<member><function>msg_set_queue</function></member>
</simplelist>
</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
-->
|