本文整理汇总了C++中Protocol::family方法的典型用法代码示例。如果您正苦于以下问题:C++ Protocol::family方法的具体用法?C++ Protocol::family怎么用?C++ Protocol::family使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Protocol
的用法示例。
在下文中一共展示了Protocol::family方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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;
}
示例2: open
bool open(const Protocol& protocol)
{
_socket = socket_ops::socket(
protocol.family(),
protocol.type(),
protocol.protocol()
);
return _socket != invalid_socket;
}
示例3:
stream_protocol( const Protocol& source_protocol )
: family_( source_protocol.family( ) ), protocol_( source_protocol.protocol( ) )
{
if ( source_protocol.type( ) != type( ) )
{
std::bad_cast ex;
asio::detail::throw_exception( ex );
}
}
示例4:
seq_packet_protocol(const Protocol& source_protocol)
: family_(source_protocol.family()),
protocol_(source_protocol.protocol())
{
if (source_protocol.type() != type())
{
std::bad_cast ex;
lslboost::asio::detail::throw_exception(ex);
}
}
示例5: connect_pair
inline BOOST_ASIO_SYNC_OP_VOID connect_pair(
basic_socket<Protocol BOOST_ASIO_SVC_TARG>& socket1,
basic_socket<Protocol BOOST_ASIO_SVC_TARG1>& 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)
BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
socket1.assign(protocol, sv[0], ec);
if (ec)
{
boost::system::error_code temp_ec;
boost::asio::detail::socket_ops::state_type state[2] = { 0, 0 };
boost::asio::detail::socket_ops::close(sv[0], state[0], true, temp_ec);
boost::asio::detail::socket_ops::close(sv[1], state[1], true, temp_ec);
BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
}
socket2.assign(protocol, sv[1], ec);
if (ec)
{
boost::system::error_code temp_ec;
socket1.close(temp_ec);
boost::asio::detail::socket_ops::state_type state = 0;
boost::asio::detail::socket_ops::close(sv[1], state, true, temp_ec);
BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
}
BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
}