| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> |
| <title>Stream-Oriented File Descriptors</title> |
| <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> |
| <meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> |
| <link rel="home" href="../../../boost_asio.html" title="Boost.Asio"> |
| <link rel="up" href="../posix.html" title="POSIX-Specific Functionality"> |
| <link rel="prev" href="local.html" title="UNIX Domain Sockets"> |
| <link rel="next" href="../windows.html" title="Windows-Specific Functionality"> |
| </head> |
| <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| <table cellpadding="2" width="100%"><tr> |
| <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> |
| <td align="center"><a href="../../../../../index.html">Home</a></td> |
| <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> |
| <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> |
| <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> |
| <td align="center"><a href="../../../../../more/index.htm">More</a></td> |
| </tr></table> |
| <hr> |
| <div class="spirit-nav"> |
| <a accesskey="p" href="local.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../posix.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../boost_asio.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../windows.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> |
| </div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h4 class="title"> |
| <a name="boost_asio.overview.posix.stream_descriptor"></a><a class="link" href="stream_descriptor.html" title="Stream-Oriented File Descriptors">Stream-Oriented |
| File Descriptors</a> |
| </h4></div></div></div> |
| <p> |
| Boost.Asio includes classes added to permit synchronous and asynchronous |
| read and write operations to be performed on POSIX file descriptors, such |
| as pipes, standard input and output, and various devices (but <span class="emphasis"><em>not</em></span> |
| regular files). |
| </p> |
| <p> |
| For example, to perform read and write operations on standard input and |
| output, the following objects may be created: |
| </p> |
| <pre class="programlisting"><span class="identifier">posix</span><span class="special">::</span><span class="identifier">stream_descriptor</span> <span class="identifier">in</span><span class="special">(</span><span class="identifier">my_io_service</span><span class="special">,</span> <span class="special">::</span><span class="identifier">dup</span><span class="special">(</span><span class="identifier">STDIN_FILENO</span><span class="special">));</span> |
| <span class="identifier">posix</span><span class="special">::</span><span class="identifier">stream_descriptor</span> <span class="identifier">out</span><span class="special">(</span><span class="identifier">my_io_service</span><span class="special">,</span> <span class="special">::</span><span class="identifier">dup</span><span class="special">(</span><span class="identifier">STDOUT_FILENO</span><span class="special">));</span> |
| </pre> |
| <p> |
| These are then used as synchronous or asynchronous read and write streams. |
| This means the objects can be used with any of the <a class="link" href="../../reference/read.html" title="read">read()</a>, |
| <a class="link" href="../../reference/async_read.html" title="async_read">async_read()</a>, <a class="link" href="../../reference/write.html" title="write">write()</a>, <a class="link" href="../../reference/async_write.html" title="async_write">async_write()</a>, |
| <a class="link" href="../../reference/read_until.html" title="read_until">read_until()</a> or |
| <a class="link" href="../../reference/async_read_until.html" title="async_read_until">async_read_until()</a> |
| free functions. |
| </p> |
| <a name="boost_asio.overview.posix.stream_descriptor.see_also"></a><h6> |
| <a name="id773559"></a> |
| <a class="link" href="stream_descriptor.html#boost_asio.overview.posix.stream_descriptor.see_also">See |
| Also</a> |
| </h6> |
| <p> |
| <a class="link" href="../../reference/posix__stream_descriptor.html" title="posix::stream_descriptor">posix::stream_descriptor</a>, |
| <a class="link" href="../../reference/posix__basic_stream_descriptor.html" title="posix::basic_stream_descriptor">posix::basic_stream_descriptor</a>, |
| <a class="link" href="../../reference/posix__stream_descriptor_service.html" title="posix::stream_descriptor_service">posix::stream_descriptor_service</a>, |
| <a class="link" href="../../examples.html#boost_asio.examples.chat">Chat example</a>. |
| </p> |
| <a name="boost_asio.overview.posix.stream_descriptor.notes"></a><h6> |
| <a name="id773624"></a> |
| <a class="link" href="stream_descriptor.html#boost_asio.overview.posix.stream_descriptor.notes">Notes</a> |
| </h6> |
| <p> |
| POSIX stream descriptors are only available at compile time if supported |
| by the target operating system. A program may test for the macro <code class="computeroutput"><span class="identifier">BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR</span></code> |
| to determine whether they are supported. |
| </p> |
| </div> |
| <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> |
| <td align="left"></td> |
| <td align="right"><div class="copyright-footer">Copyright © 2003 - 2010 Christopher M. Kohlhoff<p> |
| Distributed under the Boost Software License, Version 1.0. (See accompanying |
| file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) |
| </p> |
| </div></td> |
| </tr></table> |
| <hr> |
| <div class="spirit-nav"> |
| <a accesskey="p" href="local.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../posix.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../boost_asio.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../windows.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> |
| </div> |
| </body> |
| </html> |