<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.sem.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ru',
  ),
  'this' => 
  array (
    0 => 'function.msg-send.php',
    1 => 'msg_send',
    2 => 'Отправляет сообщение в очередь сообщений',
  ),
  'up' => 
  array (
    0 => 'ref.sem.php',
    1 => 'Функции семафоров',
  ),
  'prev' => 
  array (
    0 => 'function.msg-remove-queue.php',
    1 => 'msg_remove_queue',
  ),
  'next' => 
  array (
    0 => 'function.msg-set-queue.php',
    1 => 'msg_set_queue',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ru',
    'path' => 'reference/sem/functions/msg-send.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.msg-send" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">msg_send</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">msg_send</span> &mdash; <span class="dc-title">Отправляет сообщение в очередь сообщений</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.msg-send-description">
  <h3 class="title">Описание</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>msg_send</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="class.sysvmessagequeue.php" class="type SysvMessageQueue">SysvMessageQueue</a></span> <code class="parameter">$queue</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$message_type</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.float.php" class="type float">float</a></span>|<span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></span> <code class="parameter">$message</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$serialize</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$blocking</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter reference">&$error_code</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span><br>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="simpara">
   Функция <span class="function"><strong>msg_send()</strong></span> отправляет сообщение <code class="parameter">message</code>
   с типом <code class="parameter">message_type</code> (должно быть больше 0) в очередь сообщений,
   которую указали в параметре <code class="parameter">queue</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.msg-send-parameters">
  <h3 class="title">Список параметров</h3>
  <dl>
   
    <dt><code class="parameter">queue</code></dt>
    <dd>
     <span class="simpara">
      Очередь сообщений.
     </span>
    </dd>
   
   
    <dt><code class="parameter">message_type</code></dt>
    <dd>
     <span class="simpara">
      Тип сообщения. Значение должно быть больше 0.
     </span>
    </dd>
   
   
    <dt><code class="parameter">message</code></dt>
    <dd>
     <span class="simpara">
      Тело сообщения.
     </span>
     <blockquote class="note"><p><strong class="note">Замечание</strong>: 
      <span class="simpara">
       Если для параметра <code class="parameter">serialize</code> установили значение <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>,
       он ДОЛЖЕН принадлежать типу: <span class="type"><a href="language.types.string.php" class="type string">string</a></span>, <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>, <span class="type"><a href="language.types.float.php" class="type float">float</a></span>
       или <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>. Иначе функция выведет предупреждение.
      </span>
     </p></blockquote>
    </dd>
   
   
    <dt><code class="parameter">serialize</code></dt>
    <dd>
     <span class="simpara">
      Необязательный параметр <code class="parameter">serialize</code> управляет тем,
      как будет отправлено сообщение <code class="parameter">message</code>.
      По умолчанию <code class="parameter">serialize</code> имеет значение <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>,
      что означает сериализацию <code class="parameter">message</code> перед отправкой тем же
      механизмом, который используется модулем обработки сессий.
      Это позволяет отправлять сложные массивы и объекты в другие PHP-скрипты,
      или, если вы используете сериализацию WDDX, в другие совместимые с WDDX клиенты.
     </span>
    </dd>
   
   
    <dt><code class="parameter">blocking</code></dt>
    <dd>
     <span class="simpara">
      Если помещаемое в очередь сообщение слишком велико, ваш скрипт будет ожидать
      прочтения сообщений другим процессом и освобождения места под отправляемое вами
      сообщение.
      Это называется блокировкой; вы можете отключить эту возможность,
      установив для <code class="parameter">blocking</code> значение <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, в этом случае
      <span class="function"><strong>msg_send()</strong></span> будет немедленно возвращать <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> если сообщение
      слишком велико, и устанавливать необязательный параметр <code class="parameter">error_code</code>
      в значение <strong><code><a href="sem.constants.php#constant.msg-eagain">MSG_EAGAIN</a></code></strong>, что будет указывать вам на
      необходимость попробовать отправить сообщение несколько позже.
     </span>
    </dd>
   
   
    <dt><code class="parameter">error_code</code></dt>
    <dd>
     <span class="simpara">
      Если функция отработает неудачно, то этот код будет записан в системную переменную errno.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.msg-send-returnvalues">
  <h3 class="title">Возвращаемые значения</h3>
  <p class="simpara">
   Функция возвращает <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, если выполнилась успешно, или <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, если возникла ошибка.
  </p>
  <p class="simpara">
   При успешном завершении структура данных очереди сообщений обновится следующим образом:
   элемент <code class="parameter">msg_lspid</code> будет содержать идентификатор вызвавшего процесса,
   <code class="parameter">msg_qnum</code> увеличится на 1,
   а <code class="parameter">msg_stime</code> будет содержать текущее время.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.msg-send-changelog">
  <h3 class="title">Список изменений</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Версия</th>
      <th>Описание</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       Параметр <code class="parameter">queue</code> теперь ожидает экземпляр класса <span class="classname"><a href="class.sysvmessagequeue.php" class="classname">SysvMessageQueue</a></span>;
       раньше ожидался ресурс (<span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>).
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.msg-send-seealso">
  <h3 class="title">Смотрите также</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.msg-remove-queue.php" class="function" rel="rdfs-seeAlso">msg_remove_queue()</a> - Удаляет очередь сообщений</span></li>
   <li><span class="function"><a href="function.msg-receive.php" class="function" rel="rdfs-seeAlso">msg_receive()</a> - Получает сообщение из очереди сообщений</span></li>
   <li><span class="function"><a href="function.msg-stat-queue.php" class="function" rel="rdfs-seeAlso">msg_stat_queue()</a> - Получает информацию из структуры данных очереди сообщений</span></li>
   <li><span class="function"><a href="function.msg-set-queue.php" class="function" rel="rdfs-seeAlso">msg_set_queue()</a> - Устанавливает информацию в структуре данных очереди сообщений</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>