我最近开始与Boost Asio一起工作。我注意到receive method of a TCP socket接受message_flags作为参数。但是,我为message_flags找到的文档仅说明它是一个整数,没有指定有效值。什么是可以分配给message_flags的值,它们是什么意思?Boost Asio message_flags
9
A
回答
11
我搜索了一会儿,最后试图查看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
是可能的值。我会试一试,看看我能否让他们工作。
0
我遇到了同样的问题,我的解决方案是使用不带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)
0
相关问题
- 1. boost :: asio :: async_read和boost :: asio :: streambuf
- 2. boost boost :: asio
- 3. Boost Asio Peek和完成条件
- 4. boost asio deadline_timer
- 5. boost asio io_service.run()
- 6. Boost asio set_option error
- 7. Boost :: asio和async_read
- 8. BOOST ASIO使用
- 9. Boost asio udp waitForReadyRead
- 10. Boost(.asio)链接
- 11. boost :: asio set_option error
- 12. Boost asio and winhttp
- 13. boost :: asio :: strand && boost :: lockfree :: spsc_queue
- 14. Boost :: Asio - read或read_until?
- 15. boost :: asio通过SocketCAN
- 16. boost :: asio socket async_ * strand
- 17. Boost Asio - async stack + poll
- 18. 的boost :: ASIO检查
- 19. Boost - ASIO与IOStreams TCP
- 20. Boost ASIO ForwardIterator for streambuf
- 21. 让Boost asio工作
- 22. boost :: asio和Active Object
- 23. boost :: asio UDP广播
- 24. Boost asio io service memcpy()
- 25. Boost ASIO IO_SERVICE实现?
- 26. 的boost :: ASIO并发
- 27. Boost ASIO socket io_service.run blocking
- 28. boost :: asio :: async_read_until问题
- 29. boost :: asio :: ssl :: context :: add_verify_path
- 30. boost :: asio :: async_resolve问题
将0作为标志传递如何?它不会给你想要的行为吗? – russoue
我用0,它似乎很好 –