|
Boost Users : |
Subject: Re: [Boost-users] Boost Asio SSL can't receive without sending
From: Áõ»À½Ü (jenenliu_at_[hidden])
Date: 2016-08-22 22:47:50
it works ! thanks a lot.
------------------ Original ------------------
From: "Gavin Lambert";<gavinl_at_[hidden]>;
Date: Tue, Aug 23, 2016 07:45 AM
To: "boost-users"<boost-users_at_[hidden]>;
Subject: Re: [Boost-users] Boost Asio SSL can't receive without sending
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 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