2 / Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
8 [section:reactor Reactor-Style Operations]
10 Sometimes a program must be integrated with a third-party library that wants to
11 perform 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
14 perform the operation.
16 As an example, to perform a non-blocking read something like the
17 following may be used:
19 ip::tcp::socket socket(my_io_service);
21 socket.non_blocking(true);
23 socket.async_read_some(null_buffers(), read_handler);
25 void read_handler(boost::system::error_code ec)
29 std::vector<char> buf(socket.available());
30 socket.read_some(buffer(buf));
34 These operations are supported for sockets on all platforms, and for the POSIX
35 stream-oriented descriptor classes.
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].