Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 2652

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Performs a c library fcntl on fd</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.dio-close.html">dio_close</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.dio-open.html">dio_open</a></div>
 <div class="up"><a href="ref.dio.html">Direct IO Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.dio-fcntl" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">dio_fcntl</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5 &lt;= 5.0.5)</p><p class="refpurpose"><span class="refname">dio_fcntl</span> &mdash; <span class="dc-title">Performs a c library fcntl on fd</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.dio-fcntl-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>dio_fcntl</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$fd</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$cmd</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$args</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   The  <span class="function"><strong>dio_fcntl()</strong></span> function performs the
   operation specified by <em><code class="parameter">cmd</code></em> on the file
   descriptor <em><code class="parameter">fd</code></em>. Some commands require
   additional arguments <em><code class="parameter">args</code></em> to be supplied.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.dio-fcntl-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">fd</code></em></span>
     <dd>

      <p class="para">
       The file descriptor returned by  <span class="function"><a href="function.dio-open.html" class="function">dio_open()</a></span>.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">cmd</code></em></span>
     <dd>

      <p class="para">
       Can be one of the following operations:
       <ul class="itemizedlist">
        <li class="listitem">
         <p class="para">
          <strong><code>F_SETLK</code></strong> - Lock is set or cleared. If the lock
          is held by someone else  <span class="function"><strong>dio_fcntl()</strong></span> returns
          -1.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>F_SETLKW</code></strong> - like <strong><code>F_SETLK</code></strong>,
          but in case the lock is held by someone else, 
           <span class="function"><strong>dio_fcntl()</strong></span> waits until the lock is released.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>F_GETLK</code></strong> -  <span class="function"><strong>dio_fcntl()</strong></span> 
          returns an associative array (as described above) if someone else
          prevents lock. If there is no obstruction key &quot;type&quot; will set
          to <strong><code>F_UNLCK</code></strong>.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>F_DUPFD</code></strong> - finds the lowest numbered available
          file descriptor greater than or equal to <em><code class="parameter">args</code></em>
          and returns them.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>F_SETFL</code></strong> - Sets the file descriptors flags to 
          the value specified by <em><code class="parameter">args</code></em>, which can be
          <strong><code>O_APPEND</code></strong>, <strong><code>O_NONBLOCK</code></strong> or 
          <strong><code>O_ASYNC</code></strong>. To use <strong><code>O_ASYNC</code></strong> 
          you will need to use the <a href="ref.pcntl.html" class="link">PCNTL</a> 
          extension.
         </p>
        </li>
       </ul>
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">args</code></em></span>
     <dd>

      <p class="para">
       <em><code class="parameter">args</code></em> is an associative array, when
       <em><code class="parameter">cmd</code></em> is <strong><code>F_SETLK</code></strong> or
       <strong><code>F_SETLLW</code></strong>, with the following keys:
       <ul class="itemizedlist">
        <li class="listitem">
         <p class="para">
          <em>start</em> - offset where lock begins
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <em>length</em> - size of locked area. zero means to end
          of file
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <em>whence</em> - Where l_start is relative to: can be 
          <strong><code>SEEK_SET</code></strong>,
          <strong><code>SEEK_END</code></strong> and <strong><code>SEEK_CUR</code></strong>
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <em>type</em> - type of lock: can be
          <strong><code>F_RDLCK</code></strong> (read lock),
          <strong><code>F_WRLCK</code></strong> (write lock) or
          <strong><code>F_UNLCK</code></strong> (unlock)
         </p>
        </li>
       </ul>
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.dio-fcntl-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the result of the C call.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.dio-fcntl-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2329">
    <p><strong>Example #1 Setting and clearing a lock</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$fd&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">dio_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'/dev/ttyS0'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">O_RDWR</span><span style="color: #007700">);<br /><br />if&nbsp;(</span><span style="color: #0000BB">dio_fcntl</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">F_SETLK</span><span style="color: #007700">,&nbsp;Array(</span><span style="color: #DD0000">"type"</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">F_WRLCK</span><span style="color: #007700">))&nbsp;==&nbsp;-</span><span style="color: #0000BB">1</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;the&nbsp;file&nbsp;descriptor&nbsp;appears&nbsp;locked<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;lock&nbsp;can&nbsp;not&nbsp;be&nbsp;cleared.&nbsp;It&nbsp;is&nbsp;held&nbsp;by&nbsp;someone&nbsp;else."</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Lock&nbsp;successfully&nbsp;set/cleared"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">dio_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.dio-fcntl-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">This function is not
implemented on Windows platforms.</span></p></blockquote>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.dio-close.html">dio_close</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.dio-open.html">dio_open</a></div>
 <div class="up"><a href="ref.dio.html">Direct IO Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>