2025-01-12 20:37:50 +08:00

39 lines
1.2 KiB
Plaintext

[/
/ Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
/]
[section:pipes Pipes]
Boost.Asio provides support for portable anonymous pipes on POSIX and Windows (when
I/O completion ports are available). For example, to create and use a
connected pair of pipe objects:
boost::asio::readable_pipe read_end(my_io_context);
boost::asio::writable_pipe write_end(my_io_context);
boost::asio::connect_pipe(read_end, write_end);
write_end.async_write_some(my_write_buffer,
[](boost::system::error_code e, size_t n)
{
// ...
});
read_end.async_read_some(my_read_buffer,
[](boost::system::error_code e, size_t n)
{
// ...
});
[heading See Also]
[link boost_asio.reference.basic_readable_pipe basic_readable_pipe],
[link boost_asio.reference.basic_writable_pipe basic_writable_pipe],
[link boost_asio.reference.connect_pipe connect_pipe],
[link boost_asio.reference.readable_pipe readable_pipe],
[link boost_asio.reference.writable_pipe writable_pipe].
[endsect]