C++网络和IO开发包 Asio

openkk 13年前
     <p>Asio 是一个跨平台的C++开发包用来处理网络和低级I/O编程,通过先进的C++方法为开发人员提供连续异步模型。</p>    <p>示例代码:</p>    <pre class="brush:cpp; toolbar: true; auto-links: false;">  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)));     }   }</pre>    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1325148215608" target="_blank">http://www.open-open.com/lib/view/home/1325148215608</a></p>    <p></p>