Boost logo

Boost Users :

Subject: Re: [Boost-users] async_send handler problem
From: Igor R (boost.lists_at_[hidden])
Date: 2013-12-16 13:24:01

> --------------
> static int callback( const void *inputBuffer, void *outputBuffer, unsigned
> long framesPerBuffer,void *data ){
> if (my->streaming) my->mySender->sendIt(buffer);


> void sender::sendIt(char *charBuffer){
> sj->dFC->s->async_send_to(boost::asio::buffer(charBuffer, sj->dFC->sendBytes), *sj->dFC->e,
> boost::bind(&sender::sendHandler,this,
> boost::asio::placeholders::error,
> boost::asio::placeholders::bytes_transferred));
> sj->dFC->;
> }
> -----------------
> The good news are that it works - the bad news are: It works only once

It looks like you call io_service::run() "ad hoc", just to process the
handler of the previous async_send_to (note that it blocks until this
handler is dispatched), so every time you call async_send_to - you
call io_service::run() again. Thus, you have to call
io_service::reset() prior to any subsequent call to run():

But please note that this is untypical usage of io_service -- you
actually simulate a blocking, synchronous operation.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at