Boost logo

Boost Users :

Subject: Re: [Boost-users] Modify an asio echo server so that it does not send message back to client
From: Jonas Stöhr (stoehr_jonas_at_[hidden])
Date: 2015-06-09 15:35:52


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_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net