2011-08-17 13 views
9

私は最近Boost Asioで作業を始めました。私は、receive method of a TCP socketmessage_flagsをパラメータとして受け入れることに気づいた。しかし、message_flagsで見つかったドキュメントでは、有効な値を指定せずに整数であることだけが示されています。 message_flagsに割り当てることができる値は何ですか?その意味は何ですか?ブーストAsio message_flags

答えて

11

私はしばらくの間検索し、最後にBoostのソースコードを調べようとしました。これに基づき

/// 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_peekmessage_out_of_bandのように見える、とmessage_do_not_routeが可能な値です:私はsocket_base.hppでこれを見つけました。私はこれらを試してみると、私はそれらを働かせることができるかどうかを確認します。

0

同じ問題が発生しましたが、私の解決策はmessage_flagsパラメータ(http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/reference/basic_datagram_socket/send_to/overload1.html)を使用しない過負荷を使用することでした。

欠点は、このPARAMは、システムコールに転送され

+0

0をフラグとして渡すのはどうですか?それはあなたに望ましい行動を与えませんか? – russoue

+0

私は0を使用していました。 –

0

(過負荷が例外を使用して、とECのparamを取るdoesntの)したい場合は、エラーコードのエラーは、あなたがそれを使用傾ける報告ということです。たとえば、WindowsではWSASendに直接転送されます。 paramの意味は、OS docs:WSASend(Windowsの場合)で確認してください。それ以外の場合はrecvmsgです。

関連する問題