boost asio学习

几天发布了1.51版本,更新内容请查看: http://www.boost.org/users/history/version_1_51_0.htmlasio修改如下内容:
  • Asio:

    • Fixed an incompatibility between ip::tcp::iostream and C++11 (#7162).
    • Decorated GCC attribute names with underscores to prevent interaction with user-defined macros (#6415).
    • Added missing #include <cctype>, needed for some versions of MinGW.
    • Changed to use gcc‘s atomic builtins on ARM CPUs, when available (#7140).
    • Changed strand destruction to be a no-op, to allow strand objects to be destroyed after their associated io_service has been destroyed.
    • Added support for some newer versions of glibc which provide the epoll_create1() function but always fail with ENOSYS (#7012).
    • Changed the SSL implementation to throw an exception if SSL engine initialisation fails (#6303).
    • Fixed another regression in buffered_write_stream (#6310).
    • Implemented various minor performance improvements, primarily targeted at Linux x86 and x86-64 platforms.

对了,简单介绍一下asio吧,

原文:

Boost.Asio is a cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach.

Boost.Asio是一个跨平台的C++语言的网络和低级的I/O编程库,用现代的方法为开发者提供了一个异步模型。(翻译的不是很到位,见谅)

他的核心是boost::asio::io_service,任何一个asio程序都需要一个io_service来run。

大家其实都很清楚,网络通信的瓶颈是在I/O上,也就是I/O读写速度不够快,至少没有CPU快,所以windowsNT上提供了重叠IO的方法,我们叫他IOCP,IOCP只是一个方法而已,大家在windows上的确是将他神话了,至少他的效率不是想象中的那么高,不过处理一般的网络通信够用了。asio其实也是采用了类似的方法,不过实现过程却不相同,具体请查看http://www.boost.org/doc/libs/1_51_0/doc/html/boost_asio/overview/core/basics.html,它提供了一个io_service来连接你的程序和操作系统。

1.你的程序数据给io_object

2.io_object发送请求给io_service

3.io_service通知操作系统

4.操作系统处理完之后返回给io_service

5.你的应用程序调用io_service::run()来接收操作系统的回馈

6.io_service将结果通知应用程序中的完成句柄

这就是一个简单的asio通信处理的过程,最近我正在学习asio,准备用asio封装一个网络库,同时IOCP也在参考很多游戏源代码中的网络库,不够IOCP得自己写tcp方面的东西,我很不熟悉,所以暂时只能照猫画虎了。最后这两种库都会放出来给大家看的。

PS:最近一段时间挺消极的,不知道为何总是没心思写东西,每天看着群里讨论的热烈程度,也想自己做点东西出来。决定从现在开始正常作息时间,每天晚上写一部分东西,不论多少,至少要写出来。看到的内容需要实践才能出结果,努力吧。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值