<?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 => 'ja',
  ),
  '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' => 'ja',
    '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">queue</code>
   で指定したメッセージキューに対して <code class="parameter">message_type</code>
   で指定した型 (0 より大きい数値である必要があります) のメッセージ
   <code class="parameter">message</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> には呼び出し元のプロセス ID が
   設定され、<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> のインスタンスを期待するようになりました。
       これより前のバージョンでは、リソースが期待されていました。
      </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); ?>