reactor.qbk

来自「Boost provides free peer-reviewed portab」· QBK 代码 · 共 44 行

QBK
44
字号
[/ / Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) / / Distributed under the Boost Software License, Version 1.0. (See accompanying / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) /][section:reactor Reactor-Style Operations]Sometimes a program must be integrated with a third-party library that wants toperform the I/O operations itself. To facilitate this, Boost.Asio includes a`null_buffers` type that can be used with both read and write operations. A`null_buffers` operation doesn't return until the I/O object is "ready" toperform the operation.As an example, to perform a non-blocking read something like thefollowing may be used:  ip::tcp::socket socket(my_io_service);  ...  ip::tcp::socket::non_blocking nb(true);  socket.io_control(nb);  ...  socket.async_read_some(null_buffers(), read_handler);  ...  void read_handler(boost::system::error_code ec)  {    if (!ec)    {      std::vector<char> buf(socket.available());      socket.read_some(buffer(buf));    }  }  These operations are supported for sockets on all platforms, and for the POSIXstream-oriented descriptor classes.[heading See Also][link boost_asio.reference.null_buffers null_buffers],[link boost_asio.examples.nonblocking nonblocking example].[endsect]

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?