本文整理汇总了C++中basic_socket类的典型用法代码示例。如果您正苦于以下问题:C++ basic_socket类的具体用法?C++ basic_socket怎么用?C++ basic_socket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了basic_socket类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: connect
Iterator connect( basic_socket<Protocol, SocketService>& s,
Iterator begin,
Iterator end,
ConnectCondition connect_condition,
asio::error_code& ec )
{
ec = asio::error_code( );
for ( Iterator iter = begin; iter != end; ++iter )
{
iter = connect_condition( ec, iter );
if ( iter != end )
{
s.close( ec );
s.connect( *iter, ec );
if ( !ec )
return iter;
}
else
break;
}
if ( !ec )
ec = asio::error::not_found;
return end;
}
开发者ID:obergner,项目名称:wally-io,代码行数:27,代码来源:connect.hpp
示例2: connect_pair
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;
}
开发者ID:Barco-VCT,项目名称:VirtualClinicalTrials,代码行数:35,代码来源:connect_pair.hpp
示例3: connect
Iterator connect(basic_socket<Protocol ASIO_SVC_TARG>& s,
Iterator begin, Iterator end, ConnectCondition connect_condition,
asio::error_code& ec)
{
ec = asio::error_code();
for (Iterator iter = begin; iter != end; ++iter)
{
if (connect_condition(ec, iter))
{
s.close(ec);
s.connect(*iter, ec);
if (!ec)
return iter;
}
}
if (!ec)
ec = asio::error::not_found;
return end;
}
开发者ID:Dagarman,项目名称:mame,代码行数:22,代码来源:connect.hpp
示例4: 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);
}
开发者ID:CustomOrthopaedics,项目名称:OTS-Boost,代码行数:39,代码来源:connect_pair.hpp
注:本文中的basic_socket类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论