Hi, all
Currently, the cpp-netlib is only text protocol oriented, since the
underlying data storage facility is actually std::string (definitely
will be replaced by std::basic_string<>). This maybe enough for
protocols like http, but definitely not for binary protocols like socks.
And, I would like to have a binary protocol friendly network framework.
How about you guys? ;-)
For binary data processing abilities, I suggest the following:
* reference counted binary buffer
To avoid memory copies, reference counted binary buffer would help a
lot. I think boost::shared_ptr and boost::asio::basic_streambuf<> may
help. The asio basic_streambuf<> template is automatically resizable and
uses a vector<> for the underlying data storage. With Boost.Pool for
memory management, I think it may be an excellent choice.
* standard compliant marshalling/unmarshalling
Binary messages should be constructed easily with
marshalling/unmarshalling facilities. The library provides facilities to
marshal/unmarshal basic data types such as different kinds of (unsigned)
integers, string, sequence and array, and user can define their own
overloaded marshal/unmarshal methods to deal with user defined data
structures:
namespace network {
typedef basic_message<tag::binary_> bin_message;
} // namespace network
struct payload {
...
};
bin_message msg;
payload p;
uint32_t len = sizeof( payload )
msg
<< source( ... )
<< dest( ... ) << dest( ... )
<< marshal( len ) << marshal( p );
It also would be fine to have a standard compliant
marshalling/demarshalling policy, may be CORBA CDR could be a choice?
In one word, I'd like to have a binary message class that plays the role
of ACE_Message_Block and ACE_InputCDR/ACE_OutputCDR. What about your
opinions, guys?
Cheers
Cheng
|