提升Asio message_flags

Bri*_*ian 11 boost tcp boost-asio

我最近开始与Boost Asio合作.我注意到TCP套接字receive方法接受message_flags作为参数.但是,我在message_flags中找到的文档只说它是一个整数而没有指定有效值.可以分配给message_flags的值是什么?它们是什么意思?

Bri*_*ian 12

我搜索了一会儿,最后试着查看Boost的源代码.我在socket_base.hpp中找到了这个:

  /// Bitmask type for flags that can be passed to send and receive operations.
  typedef int message_flags;

#if defined(GENERATING_DOCUMENTATION)
  /// Peek at incoming data without removing it from the input queue.
  static const int message_peek = implementation_defined;

  /// Process out-of-band data.
  static const int message_out_of_band = implementation_defined;

  /// Specify that the data should not be subject to routing.
  static const int message_do_not_route = implementation_defined;
#else
  BOOST_STATIC_CONSTANT(int,
      message_peek = boost::asio::detail::message_peek);
  BOOST_STATIC_CONSTANT(int,
      message_out_of_band = boost::asio::detail::message_out_of_band);
  BOOST_STATIC_CONSTANT(int,
      message_do_not_route = boost::asio::detail::message_do_not_route);
#endif
Run Code Online (Sandbox Code Playgroud)

在此基础上,它看起来像message_peek,message_out_of_band以及message_do_not_route有可能的值.我打算尝试一下,看看能不能让他们上班.