我最近開始與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,它似乎很好 –