我最近开始与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 Asio Peek和完成条件
- 3. boost asio io_service.run()
- 4. Boost asio udp waitForReadyRead
- 5. Boost asio and winhttp
- 6. boost asio deadline_timer
- 7. boost :: asio :: strand && boost :: lockfree :: spsc_queue
- 8. boost :: asio和Active Object
- 9. Boost ASIO IO_SERVICE实现?
- 10. boost :: asio :: async_read_until问题
- 11. 的boost :: ASIO检查
- 12. boost :: asio :: streambuf为空?
- 13. 掌握的boost :: ASIO
- 14. boost :: asio UDP广播
- 15. Boost ASIO socket io_service.run blocking
- 16. boost :: asio :: async_resolve问题
- 17. 的boost :: ASIO async_read_some async_read_until编译器警告
- 18. boost :: asio :: write似乎不工作,而boost :: asio :: read是优秀的
- 19. boost :: asio :: ssl :: context :: context(boost :: asio :: ssl :: context_base :: method)undefined符号
- 20. 何时调用boost :: asio :: streambuf :: consume()和boost :: asio :: streambuf :: commit()?
- 21. boost :: asio :: windows :: stream_handle in boost 1.46.1在哪里?
- 22. 从boost :: threads到boost :: asio定时器
- 23. 使用boost :: asio :: async_read和stdin?
- 24. Boost asio ConstBufferSequence - C++模板
- 25. Boost :: Asio - 引发get_io_service异常
- 26. Boost :: Asio读/写操作
- 27. boost asio和shared_ptrs的扩散
- 28. “两步”async_read with boost asio
- 29. TCPClient boost :: asio :: io_service post not firing
- 30. Boost Asio GCC链接错误
将0作为标志传递如何?它不会给你想要的行为吗? – russoue
我用0,它似乎很好 –