]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/asio/doc/overview/streams.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / asio / doc / overview / streams.qbk
CommitLineData
7c673cae
FG
1[/
2 / Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
3 /
4 / Distributed under the Boost Software License, Version 1.0. (See accompanying
5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 /]
7
8[section:streams Streams, Short Reads and Short Writes]
9
10Many I/O objects in Boost.Asio are stream-oriented. This means that:
11
12* There are no message boundaries. The data being transferred is a continuous
13 sequence of bytes.
14
15* Read or write operations may transfer fewer bytes than requested. This is
16 referred to as a short read or short write.
17
18Objects that provide stream-oriented I/O model one or more of the following
19type requirements:
20
21* `SyncReadStream`, where synchronous read operations are performed using a
22 member function called `read_some()`.
23
24* `AsyncReadStream`, where asynchronous read operations are performed using a
25 member function called `async_read_some()`.
26
27* `SyncWriteStream`, where synchronous write operations are performed using a
28 member function called `write_some()`.
29
30* `AsyncWriteStream`, where synchronous write operations are performed using a
31 member function called `async_write_some()`.
32
33Examples of stream-oriented I/O objects include `ip::tcp::socket`,
34`ssl::stream<>`, `posix::stream_descriptor`, `windows::stream_handle`, etc.
35
36Programs typically want to transfer an exact number of bytes. When a short read
37or short write occurs the program must restart the operation, and continue to
38do so until the required number of bytes has been transferred. Boost.Asio provides
39generic functions that do this automatically: `read()`, `async_read()`,
40`write()` and `async_write()`.
41
42[heading Why EOF is an Error]
43
44* The end of a stream can cause `read`, `async_read`, `read_until` or
45 `async_read_until` functions to violate their contract. E.g.
46 a read of N bytes may finish early due to EOF.
47
48* An EOF error may be used to distinguish the end of a stream from a successful
49 read of size 0.
50
51[heading See Also]
52
53[link boost_asio.reference.async_read async_read()],
54[link boost_asio.reference.async_write async_write()],
55[link boost_asio.reference.read read()],
56[link boost_asio.reference.write write()],
57[link boost_asio.reference.AsyncReadStream AsyncReadStream],
58[link boost_asio.reference.AsyncWriteStream AsyncWriteStream],
59[link boost_asio.reference.SyncReadStream SyncReadStream],
60[link boost_asio.reference.SyncWriteStream SyncWriteStream].
61
62[endsect]