summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-06-01 08:48:42 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-06-01 09:24:28 (GMT)
commit2812bddd81f8a1b804c7460f4e14cd0aa393d129 (patch)
treed46294f35150c4f0f43deaf2d31fceaf945ae715 /3rdParty/Boost/boost/asio/local/connect_pair.hpp
downloadswift-contrib-2812bddd81f8a1b804c7460f4e14cd0aa393d129.zip
swift-contrib-2812bddd81f8a1b804c7460f4e14cd0aa393d129.tar.bz2
Import.
Diffstat (limited to '3rdParty/Boost/boost/asio/local/connect_pair.hpp')
-rw-r--r--3rdParty/Boost/boost/asio/local/connect_pair.hpp102
1 files changed, 102 insertions, 0 deletions
diff --git a/3rdParty/Boost/boost/asio/local/connect_pair.hpp b/3rdParty/Boost/boost/asio/local/connect_pair.hpp
new file mode 100644
index 0000000..39a5e2a
--- /dev/null
+++ b/3rdParty/Boost/boost/asio/local/connect_pair.hpp
@@ -0,0 +1,102 @@
+//
+// connect_pair.hpp
+// ~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2008 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)
+//
+
+#ifndef BOOST_ASIO_LOCAL_CONNECT_PAIR_HPP
+#define BOOST_ASIO_LOCAL_CONNECT_PAIR_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/push_options.hpp>
+
+#include <boost/asio/basic_socket.hpp>
+#include <boost/asio/error.hpp>
+#include <boost/asio/local/basic_endpoint.hpp>
+#include <boost/asio/detail/socket_ops.hpp>
+#include <boost/asio/detail/throw_error.hpp>
+
+#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) \
+ || defined(GENERATING_DOCUMENTATION)
+
+namespace boost {
+namespace asio {
+namespace local {
+
+/// Create a pair of connected sockets.
+template <typename Protocol, typename SocketService1, typename SocketService2>
+void connect_pair(
+ basic_socket<Protocol, SocketService1>& socket1,
+ basic_socket<Protocol, SocketService2>& socket2);
+
+/// Create a pair of connected sockets.
+template <typename Protocol, typename SocketService1, typename SocketService2>
+boost::system::error_code connect_pair(
+ basic_socket<Protocol, SocketService1>& socket1,
+ basic_socket<Protocol, SocketService2>& socket2,
+ boost::system::error_code& ec);
+
+template <typename Protocol, typename SocketService1, typename SocketService2>
+inline void connect_pair(
+ basic_socket<Protocol, SocketService1>& socket1,
+ basic_socket<Protocol, SocketService2>& socket2)
+{
+ boost::system::error_code ec;
+ connect_pair(socket1, socket2, ec);
+ boost::asio::detail::throw_error(ec);
+}
+
+template <typename Protocol, typename SocketService1, typename SocketService2>
+inline boost::system::error_code connect_pair(
+ basic_socket<Protocol, SocketService1>& socket1,
+ basic_socket<Protocol, SocketService2>& socket2,
+ boost::system::error_code& ec)
+{
+ // Check that this function is only being used with a UNIX domain socket.
+ boost::asio::local::basic_endpoint<Protocol>* tmp
+ = static_cast<typename Protocol::endpoint*>(0);
+ (void)tmp;
+
+ Protocol protocol;
+ boost::asio::detail::socket_type sv[2];
+ if (boost::asio::detail::socket_ops::socketpair(protocol.family(),
+ protocol.type(), protocol.protocol(), sv, ec)
+ == boost::asio::detail::socket_error_retval)
+ return ec;
+
+ if (socket1.assign(protocol, sv[0], ec))
+ {
+ boost::system::error_code temp_ec;
+ boost::asio::detail::socket_ops::close(sv[0], temp_ec);
+ boost::asio::detail::socket_ops::close(sv[1], temp_ec);
+ return ec;
+ }
+
+ if (socket2.assign(protocol, sv[1], ec))
+ {
+ boost::system::error_code temp_ec;
+ socket1.close(temp_ec);
+ boost::asio::detail::socket_ops::close(sv[1], temp_ec);
+ return ec;
+ }
+
+ return ec;
+}
+
+} // namespace local
+} // namespace asio
+} // namespace boost
+
+#endif // defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
+ // || defined(GENERATING_DOCUMENTATION)
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // BOOST_ASIO_LOCAL_CONNECT_PAIR_HPP