Boost logo

Boost Users :

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


> Yes, I truly understand this but for some weired reason this doesn't work
> at all. In my case I launch the run function in the constructor of the
> main class right after the sender class had been instantiated:
>
> SJ::SJ(){
>
> /// SENDER INIT
> dFC->mySender = new sender(this);
>
>
> boost::thread t =
> boost::thread(boost::bind(&boost::asio::io_service::run,
> &dFC->io_service));
> t.join();
>
> // OR dFC->io_service.run();
> }
>
>
> In there anything wrong with this ?

It seems that you call io_serivce::run() before any async operation
was issued. In such a case, run() just exits immediately, as I
explained in one of my previous comments. In order to avoid such a
behavior,
associate io_service::work object with this io_service:
http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/reference/io_service.html
(scroll down)

In general, it's highly recommended to read the Asio documentation -
all these issues are described there.


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