Hi Jonas,

  Yes, I want to keep reading data an process them. Here is my implementation base on my understanding of your suggestion:

class session
{
public:
session(boost::asio::io_service& io_service)
: socket_(io_service)
{
}

tcp::socket& socket()
{
return socket_;
}

void start()
{
socket_.async_read_some(boost::asio::buffer(data_, max_length),
boost::bind(&session::handle_read, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}

void handle_read(const boost::system::error_code& error,
size_t bytes_transferred)
{
if (!error)
{
std::cout << boost::format("handle_read bytes_transferred ='%1%'") % bytes_transferred << std::endl;
process(data_);
socket_.async_read_some(boost::asio::buffer(data_, max_length),
boost::bind(&session::handle_read, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
std::cout << boost::format("handle_read data_ ='%1%'") % data_ << std::endl;
}
else
{
delete this;
}
}

void process(char *data)
{
std::cout << boost::format("process data_ ='%1%'") % data_ << std::endl;
}

private:
tcp::socket socket_;
enum { max_length = 1024 };
char data_[max_length];
};

Cheers

On 9 June 2015 at 12:35, Jonas Stöhr <stoehr_jonas@web.de> wrote:
So if I understand you correctly, you just want to keep reading the data
asynchronously and process them without sending them back?
Basically remove the ba::async_write from handle_read them, put your
processing code there within the if(!error)-Block instead and then after
processing just start another read the same way it is done in
handle_write (you don't need handle_write anymore then):

..
if (!error)
{
  process(data_);
  socket_.async_read_some(boost::asio::buffer(data_, max_length),
    boost::bind(&session::handle_read, this,
      boost::asio::placeholders::error,
      boost::asio::placeholder::bytes_transferred));
}
..

Am 09.06.2015 um 21:22 schrieb Nicholas Yue:
> Hi,
>
>   I am writing a simple server that is listening to binary data bucket
> being sent by a client.
>
>   I am basing the prototype server on the following:
>
> http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/example/cpp03/echo/async_tcp_echo_server.cpp
>
>   I am wonder what is the correct way to modify the example so that it
> does not echo the result back to the client. The amount of binary data
> sent are substantial, more importantly, the client has no way to handle
> the incoming data on the socket.
>
> Cheers
> --
> Nicholas Yue
> Graphics - Arnold, Alembic, RenderMan, OpenGL, HDF5
> Custom Dev - C++ porting, OSX, Linux, Windows
> http://au.linkedin.com/in/nicholasyue
> https://vimeo.com/channels/naiadtools
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users@lists.boost.org
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users



--
Nicholas Yue
Graphics - Arnold, Alembic, RenderMan, OpenGL, HDF5
Custom Dev - C++ porting, OSX, Linux, Windows
http://au.linkedin.com/in/nicholasyue
https://vimeo.com/channels/naiadtools