Imported Upstream version 1.64.0
[platform/upstream/boost.git] / doc / html / boost_asio / overview / posix / stream_descriptor.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Stream-Oriented File Descriptors</title>
5 <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../../boost_asio.html" title="Boost.Asio">
8 <link rel="up" href="../posix.html" title="POSIX-Specific Functionality">
9 <link rel="prev" href="local.html" title="UNIX Domain Sockets">
10 <link rel="next" href="fork.html" title="Fork">
11 </head>
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../more/index.htm">More</a></td>
20 </tr></table>
21 <hr>
22 <div class="spirit-nav">
23 <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="fork.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="section">
26 <div class="titlepage"><div><div><h4 class="title">
27 <a name="boost_asio.overview.posix.stream_descriptor"></a><a class="link" href="stream_descriptor.html" title="Stream-Oriented File Descriptors">Stream-Oriented
28         File Descriptors</a>
29 </h4></div></div></div>
30 <p>
31           Boost.Asio includes classes added to permit synchronous and asynchronous
32           read and write operations to be performed on POSIX file descriptors, such
33           as pipes, standard input and output, and various devices.
34         </p>
35 <p>
36           These classes also provide limited support for regular files. This support
37           assumes that the underlying read and write operations provided by the operating
38           system never fail with <code class="computeroutput"><span class="identifier">EAGAIN</span></code>
39           or <code class="computeroutput"><span class="identifier">EWOULDBLOCK</span></code>. (This assumption
40           normally holds for buffered file I/O.) Synchronous and asynchronous read
41           and write operations on file descriptors will succeed but the I/O will
42           always be performed immediately. Wait operations, and operations involving
43           <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">null_buffers</span></code>, are not portably supported.
44         </p>
45 <p>
46           For example, to perform read and write operations on standard input and
47           output, the following objects may be created:
48         </p>
49 <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>
50 <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>
51 </pre>
52 <p>
53           These are then used as synchronous or asynchronous read and write streams.
54           This means the objects can be used with any of the <a class="link" href="../../reference/read.html" title="read">read()</a>,
55           <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>,
56           <a class="link" href="../../reference/read_until.html" title="read_until">read_until()</a> or
57           <a class="link" href="../../reference/async_read_until.html" title="async_read_until">async_read_until()</a>
58           free functions.
59         </p>
60 <h6>
61 <a name="boost_asio.overview.posix.stream_descriptor.h0"></a>
62           <span class="phrase"><a name="boost_asio.overview.posix.stream_descriptor.see_also"></a></span><a class="link" href="stream_descriptor.html#boost_asio.overview.posix.stream_descriptor.see_also">See Also</a>
63         </h6>
64 <p>
65           <a class="link" href="../../reference/posix__stream_descriptor.html" title="posix::stream_descriptor">posix::stream_descriptor</a>,
66           <a class="link" href="../../reference/posix__basic_stream_descriptor.html" title="posix::basic_stream_descriptor">posix::basic_stream_descriptor</a>,
67           <a class="link" href="../../reference/posix__stream_descriptor_service.html" title="posix::stream_descriptor_service">posix::stream_descriptor_service</a>,
68           <a class="link" href="../../examples/cpp03_examples.html#boost_asio.examples.cpp03_examples.chat">Chat example (C++03)</a>,
69           <a class="link" href="../../examples/cpp11_examples.html#boost_asio.examples.cpp11_examples.chat">Chat example (C++11)</a>.
70         </p>
71 <h6>
72 <a name="boost_asio.overview.posix.stream_descriptor.h1"></a>
73           <span class="phrase"><a name="boost_asio.overview.posix.stream_descriptor.notes"></a></span><a class="link" href="stream_descriptor.html#boost_asio.overview.posix.stream_descriptor.notes">Notes</a>
74         </h6>
75 <p>
76           POSIX stream descriptors are only available at compile time if supported
77           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>
78           to determine whether they are supported.
79         </p>
80 </div>
81 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
82 <td align="left"></td>
83 <td align="right"><div class="copyright-footer">Copyright &#169; 2003-2017 Christopher M. Kohlhoff<p>
84         Distributed under the Boost Software License, Version 1.0. (See accompanying
85         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>)
86       </p>
87 </div></td>
88 </tr></table>
89 <hr>
90 <div class="spirit-nav">
91 <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="fork.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
92 </div>
93 </body>
94 </html>