-------------- 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->io_service.run(); } -----------------
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(): http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/reference/io_servic... But please note that this is untypical usage of io_service -- you actually simulate a blocking, synchronous operation.