2 // impl/connect_pipe.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_IMPL_CONNECT_PIPE_HPP
12 #define BOOST_ASIO_IMPL_CONNECT_PIPE_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
20 #if defined(BOOST_ASIO_HAS_PIPE)
22 #include <boost/asio/connect_pipe.hpp>
23 #include <boost/asio/detail/throw_error.hpp>
25 #include <boost/asio/detail/push_options.hpp>
30 template <typename Executor1, typename Executor2>
31 void connect_pipe(basic_readable_pipe<Executor1>& read_end,
32 basic_writable_pipe<Executor2>& write_end)
34 boost::system::error_code ec;
35 boost::asio::connect_pipe(read_end, write_end, ec);
36 boost::asio::detail::throw_error(ec, "connect_pipe");
39 template <typename Executor1, typename Executor2>
40 BOOST_ASIO_SYNC_OP_VOID connect_pipe(basic_readable_pipe<Executor1>& read_end,
41 basic_writable_pipe<Executor2>& write_end, boost::system::error_code& ec)
43 detail::native_pipe_handle p[2];
44 detail::create_pipe(p, ec);
46 BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
48 read_end.assign(p[0], ec);
51 detail::close_pipe(p[0]);
52 detail::close_pipe(p[1]);
53 BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
56 write_end.assign(p[1], ec);
59 boost::system::error_code temp_ec;
60 read_end.close(temp_ec);
61 detail::close_pipe(p[1]);
62 BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
65 BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
71 #include <boost/asio/detail/pop_options.hpp>
73 #endif // defined(BOOST_ASIO_HAS_PIPE)
75 #endif // BOOST_ASIO_IMPL_CONNECT_PIPE_HPP