Asio 介绍
Asio 是一个跨平台的C开发包用来处理网络和低级I/O编程,通过先进的C方法为开发人员提供连续异步模型。
示例代码:
void handle_read(const asio::error_code& error,
size_t bytes_transferred)
{
if (!error)
{
asio::async_write(socket_,
asio::buffer(data_, bytes_transferred),
make_custom_alloc_handler(allocator_,
boost::bind(&session::handle_write,
shared_from_this(),
asio::placeholders::error)));
}
}
void handle_write(const asio::error_code& error)
{
if (!error)
{
socket_.async_read_some(asio::buffer(data_),
make_custom_alloc_handler(allocator_,
boost::bind(&session::handle_read,
shared_from_this(),
asio::placeholders::error,
asio::placeholders::bytes_transferred)));
}
}
Asio 官网
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。