// --- stub library headers --- namespace std { typedef unsigned long size_t; #define SIZE_MAX 0xFFFFFFFF template class allocator { }; template struct char_traits { }; template, class Allocator = allocator > class basic_string { public: basic_string(const charT* s, const Allocator& a = Allocator()); }; typedef basic_string string; }; namespace boost { namespace system { class error_code { public: operator bool() const; }; }; namespace asio { template class basic_stream_socket /*: public basic_socket*/ { }; namespace ip { class tcp { public: typedef basic_stream_socket socket; }; }; template> class basic_streambuf { public: basic_streambuf( std::size_t maximum_size = SIZE_MAX, const Allocator &allocator = Allocator()); }; typedef basic_streambuf<> streambuf; class mutable_buffer { }; template mutable_buffer buffer(std::basic_string & data); template std::size_t read_until( SyncReadStream &s, asio::basic_streambuf &b, char delim, boost::system::error_code &ec); template std::size_t write( SyncWriteStream &s, const ConstBufferSequence &buffers, boost::system::error_code &ec, int constraint = 0); // simplified }; }; // --- test code --- void test(boost::asio::ip::tcp::socket &socket) { boost::asio::streambuf recv_buffer; boost::system::error_code error; boost::asio::read_until(socket, recv_buffer, '\0', error); // $ remote_source if (error) { // ... } std::string send_str = std::string("message"); boost::asio::mutable_buffer send_buffer = boost::asio::buffer(send_str); boost::asio::write(socket, send_buffer, error); // $ remote_sink if (error) { // ... } }