Boost 增强Asio消息\u标志
我最近开始与Boost Asio合作。我注意到接受a作为参数。但是,我找到的有关message_标志的文档只说它是一个整数,没有指定有效值。可以分配给消息标志的值是什么?它们是什么意思?我搜索了一会儿,最后尝试查找Boost的源代码。我发现这一点:Boost 增强Asio消息\u标志,boost,tcp,boost-asio,Boost,Tcp,Boost Asio,我最近开始与Boost Asio合作。我注意到接受a作为参数。但是,我找到的有关message_标志的文档只说它是一个整数,没有指定有效值。可以分配给消息标志的值是什么?它们是什么意思?我搜索了一会儿,最后尝试查找Boost的源代码。我发现这一点: 基于此,可能的值可能是message\u peek、message\u out\u of\u band、以及message\u do\u not\u route。我将尝试一下,看看是否可以让它们工作。我遇到了同样的问题,我的解决方案是使用不带mess
基于此,可能的值可能是
message\u peek
、message\u out\u of\u band
、以及message\u do\u not\u route
。我将尝试一下,看看是否可以让它们工作。我遇到了同样的问题,我的解决方案是使用不带message_flags参数()的重载
缺点是,如果您想要错误代码错误报告,您不能使用它(重载使用异常,并且不接受ec参数)此参数被转发到系统调用。例如,在Windows中,它直接转发到WSASend。应在操作系统文档中检查参数的含义:否则为Windows。将0作为标志传递如何?它不会给你想要的行为吗?我使用了0,它看起来很好
/// 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;
/// Specifies that the data marks the end of a record.
static const int message_end_of_record = implementation_defined;
#else
BOOST_ASIO_STATIC_CONSTANT(int,
message_peek = BOOST_ASIO_OS_DEF(MSG_PEEK));
BOOST_ASIO_STATIC_CONSTANT(int,
message_out_of_band = BOOST_ASIO_OS_DEF(MSG_OOB));
BOOST_ASIO_STATIC_CONSTANT(int,
message_do_not_route = BOOST_ASIO_OS_DEF(MSG_DONTROUTE));
BOOST_ASIO_STATIC_CONSTANT(int,
message_end_of_record = BOOST_ASIO_OS_DEF(MSG_EOR));
#endif