]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/asio/doc/overview/reactor.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / asio / doc / overview / reactor.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:reactor Reactor-Style Operations]
9
10Sometimes a program must be integrated with a third-party library that wants to
11perform the I/O operations itself. To facilitate this, Boost.Asio includes a
12`null_buffers` type that can be used with both read and write operations. A
13`null_buffers` operation doesn't return until the I/O object is "ready" to
14perform the operation.
15
16As an example, to perform a non-blocking read something like the
17following may be used:
18
19 ip::tcp::socket socket(my_io_service);
20 ...
21 socket.non_blocking(true);
22 ...
23 socket.async_read_some(null_buffers(), read_handler);
24 ...
25 void read_handler(boost::system::error_code ec)
26 {
27 if (!ec)
28 {
29 std::vector<char> buf(socket.available());
30 socket.read_some(buffer(buf));
31 }
32 }
33
34These operations are supported for sockets on all platforms, and for the POSIX
35stream-oriented descriptor classes.
36
37[heading See Also]
38
39[link boost_asio.reference.null_buffers null_buffers],
40[link boost_asio.reference.basic_socket.non_blocking basic_socket::non_blocking()],
41[link boost_asio.reference.basic_socket.native_non_blocking basic_socket::native_non_blocking()],
42[link boost_asio.examples.cpp03_examples.nonblocking nonblocking example].
43
44[endsect]