<!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>Get stream representing a variable used in internal communications with libeio.</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.eio-futime.html">eio_futime</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.eio-get-last-error.html">eio_get_last_error</a></div> <div class="up"><a href="ref.eio.html">Eio Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.eio-get-event-stream" class="refentry"> <div class="refnamediv"> <h1 class="refname">eio_get_event_stream</h1> <p class="verinfo">(PECL eio >= 0.3.1b)</p><p class="refpurpose"><span class="refname">eio_get_event_stream</span> — <span class="dc-title">Get stream representing a variable used in internal communications with libeio.</span></p> </div> <div class="refsect1 description" id="refsect1-function.eio-get-event-stream-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>eio_get_event_stream</strong></span> ( <span class="methodparam">void</span> )</div> <p class="para rdfs-comment"> <span class="function"><strong>eio_get_event_stream()</strong></span> acquires stream representing a variable used in internal communications with libeio. Could be used to bind with some event loop provided by other PECL extension, for example libevent. </p> </div> <div class="refsect1 parameters" id="refsect1-function.eio-get-event-stream-parameters"> <h3 class="title">Parameters</h3> <p class="para">This function has no parameters.</p> </div> <div class="refsect1 returnvalues" id="refsect1-function.eio-get-event-stream-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> <span class="function"><strong>eio_get_event_stream()</strong></span> returns stream on success; otherwise, <strong><code>NULL</code></strong> </p> </div> <div class="refsect1 examples" id="refsect1-function.eio-get-event-stream-examples"> <h3 class="title">Examples</h3> <div class="example" id="example-3591"> <p><strong>Example #1 Using eio with libevent</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">my_eio_poll</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">, </span><span style="color: #0000BB">$events</span><span style="color: #007700">, </span><span style="color: #0000BB">$arg</span><span style="color: #007700">) {<br /> </span><span style="color: #FF8000">/* Some libevent regulation might go here .. */<br /> </span><span style="color: #007700">if (</span><span style="color: #0000BB">eio_nreqs</span><span style="color: #007700">()) {<br /> </span><span style="color: #0000BB">eio_poll</span><span style="color: #007700">();<br /> }<br /> </span><span style="color: #FF8000">/* .. and here */<br /></span><span style="color: #007700">}<br /><br />function </span><span style="color: #0000BB">my_res_cb</span><span style="color: #007700">(</span><span style="color: #0000BB">$d</span><span style="color: #007700">, </span><span style="color: #0000BB">$r</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$r</span><span style="color: #007700">); </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$d</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$base </span><span style="color: #007700">= </span><span style="color: #0000BB">event_base_new</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$event </span><span style="color: #007700">= </span><span style="color: #0000BB">event_new</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$fd </span><span style="color: #007700">= </span><span style="color: #0000BB">eio_get_event_stream</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">eio_nop</span><span style="color: #007700">(</span><span style="color: #0000BB">EIO_PRI_DEFAULT</span><span style="color: #007700">, </span><span style="color: #DD0000">"my_res_cb"</span><span style="color: #007700">, </span><span style="color: #DD0000">"nop data"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">eio_mkdir</span><span style="color: #007700">(</span><span style="color: #DD0000">"/tmp/abc-eio-temp"</span><span style="color: #007700">, </span><span style="color: #0000BB">0750</span><span style="color: #007700">, </span><span style="color: #0000BB">EIO_PRI_DEFAULT</span><span style="color: #007700">, </span><span style="color: #DD0000">"my_res_cb"</span><span style="color: #007700">, </span><span style="color: #DD0000">"mkdir data"</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">/* some other eio_* calls here ... */<br /><br /><br />// set event flags<br /></span><span style="color: #0000BB">event_set</span><span style="color: #007700">(</span><span style="color: #0000BB">$event</span><span style="color: #007700">, </span><span style="color: #0000BB">$fd</span><span style="color: #007700">, </span><span style="color: #0000BB">EV_READ </span><span style="color: #FF8000">/*| EV_PERSIST*/</span><span style="color: #007700">, </span><span style="color: #DD0000">"my_eio_poll"</span><span style="color: #007700">, array(</span><span style="color: #0000BB">$event</span><span style="color: #007700">, </span><span style="color: #0000BB">$base</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// set event base <br /></span><span style="color: #0000BB">event_base_set</span><span style="color: #007700">(</span><span style="color: #0000BB">$event</span><span style="color: #007700">, </span><span style="color: #0000BB">$base</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// enable event<br /></span><span style="color: #0000BB">event_add</span><span style="color: #007700">(</span><span style="color: #0000BB">$event</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// start event loop<br /></span><span style="color: #0000BB">event_base_loop</span><span style="color: #007700">(</span><span style="color: #0000BB">$base</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* The same will be available via buffered libevent interface */<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output something similar to:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> int(3) int(0) string(8) "nop data" int(0) string(10) "mkdir data" </pre></div> </div> </div> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.eio-futime.html">eio_futime</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.eio-get-last-error.html">eio_get_last_error</a></div> <div class="up"><a href="ref.eio.html">Eio Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>