|
Boost Users : |
Subject: Re: [Boost-users] Boost Asio SSL can't receive without sending
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2016-08-22 19:45:01
On 23/08/2016 01:52, Richard Hodges wrote:
> once io_service::run() returns, the io_service will be in the stopped()
> state. This happens when there are no remaining async operations waiting
> to complete on it. In a multi-threaded environment you must keep the
> io_service running by creating an io_service::work object against it.
> Then when you want to stop your communications loop, you would call
> op_service::stop() and join the threads.
Actually that's not strictly true. As long as any operation or handler
is pending, the io_service won't stop on its own. So if you ensure that
your async_read handler always starts another async_read (and if the
socket disconnects you immediately reconnect it), then you don't need
io_service::work; you only need that if there can be "dead times" when
no async operation is pending.
It's usually simpler to use it than not to, though.
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