我最近开始与Boost Asio合作。我注意到了 接收TCP套接字的方法 接受一个 message_flags 作为参数。但是,我在message_flags中找到的文档只说它是一个整数而没有指定有效值。可以分配给message_flags的值是什么?它们是什么意思?
我最近开始与Boost Asio合作。我注意到了 接收TCP套接字的方法 接受一个 message_flags 作为参数。但是,我在message_flags中找到的文档只说它是一个整数而没有指定有效值。可以分配给message_flags的值是什么?它们是什么意思?
我搜索了一会儿,最后试着查看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
基于此,它看起来像 message_peek
, message_out_of_band
,和 message_do_not_route
是可能的值。我打算尝试一下,看看能不能让他们上班。
我遇到了同样的问题,我的解决方案是使用不带message_flags参数的重载(http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/reference/basic_datagram_socket/send_to/overload1.html )。
缺点是如果你想要错误代码错误报告你不能使用它(重载使用异常,并没有采取ec param)
我搜索了一会儿,最后试着查看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
基于此,它看起来像 message_peek
, message_out_of_band
,和 message_do_not_route
是可能的值。我打算尝试一下,看看能不能让他们上班。
我遇到了同样的问题,我的解决方案是使用不带message_flags参数的重载(http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/reference/basic_datagram_socket/send_to/overload1.html )。
缺点是如果你想要错误代码错误报告你不能使用它(重载使用异常,并没有采取ec param)