<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>There is actually quite some descent docs to read here:</div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><a href="http://www.erlang.org/doc/apps/erts/index.html">http://www.erlang.org/doc/apps/erts/index.html</a></div><div><br class="webkit-block-placeholder"></div><span class="Apple-style-span" style="font-family: Verdana; font-size: 16px; "><p><a name="void outputv/2"><span class="bold_code" style="font-family: courier; font-weight: bold; ">void outputv(ErlDrvData drv_data, ErlIOVec *ev)</span></a><br></p><div class="REFBODY" style="margin-left: 13mm; "><a name="outputv"></a><p>This function is called whenever the port is written to. If it is <span class="code" style="font-family: courier; font-weight: normal; ">NULL</span>, the <span class="code" style="font-family: courier; font-weight: normal; ">output</span> function is called instead. This function is faster than <span class="code" style="font-family: courier; font-weight: normal; ">output</span>, because it takes an <span class="code" style="font-family: courier; font-weight: normal; ">ErlIOVec</span> directly, which requires no copying of the data. The port should be in binary mode, see <span class="code" style="font-family: courier; font-weight: normal; ">open_port/2</span>.</p><p>The <span class="code" style="font-family: courier; font-weight: normal; ">ErlIOVec</span> contains both a <span class="code" style="font-family: courier; font-weight: normal; ">SysIOVec</span>, suitable for <span class="code" style="font-family: courier; font-weight: normal; ">writev</span>, and one or more binaries. If these binaries should be retained, when the driver returns from <span class="code" style="font-family: courier; font-weight: normal; ">outputv</span>, they can be queued (using <a href="http://www.erlang.org/doc/man/erl_driver.html#driver_enq_bin">driver_enq_bin</a> for instance), or if they are kept in a static or global variable, the reference counter can be incremented.</p></div></span><div><div>On 13 dec 2007, at 20.15, Joel Reymont wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">I'm studying the source for the efile driver in efile_drv.c as well as  <br>the matching Erlang code in prim_file.erl.<br><br>For the life of me I cannot figure out how FILE_WRITE gets to be  <br>handled in file_outputv and FILE_MKDIR in file_output. Both are  <br>triggered from port_command/2 on the Erlang side and both callbacks  <br>are set in the driver entry structure.<br><br>How does the runtime figure out whether to call the output callback or  <br>the outputv callback when both are supplied?<br><br>According to erts_write_to_port in erts/emulator/beam/io.c, the output  <br>callback will never be called when the output callback is present the  <br>function checks for outputv first.<br><br><span class="Apple-tab-span" style="white-space:pre"> </span>Thanks, Joel<br><br>--<br><a href="http://wagerlabs.com">http://wagerlabs.com</a><br><br><br><br><br><br>_______________________________________________<br>erlang-questions mailing list<br>erlang-questions@erlang.org<br>http://www.erlang.org/mailman/listinfo/erlang-questions<br></blockquote></div><br></body></html>