Boost Asio SSL can't receive without sending
Hi, I am using Boost Asio to developed a server, with SSL support. I add async_read_some() function in handshake handler and send handler. Which receiving is OK if I send something to clients, but I can't keep receiving after I stop sending things to client. So I am wondering how can I keep receiving, I know there must be a way to make it, I am new to Asio, can someone help, thanks in advance. ------------------ I won't go
Are you calling run( ) on the ioservice ( boost::asio::io_service ) ?
Radu
From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of ???
Sent: 19 August 2016 07:57
To: boost-users
A. did you forget to have an async_read_some active?
B. did your io_service stop because you forgot to give it
asio::io_service::work?
C. did you call shutdown() or close() on the underlying protocol?
D. What is the exact error_code.value(), .category() and .message()?
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.
Can you post a minimal complete example somewhere which demonstrates the
problem?
R
On 19 August 2016 at 08:57, 刘焕杰
Hi, I am using Boost Asio to developed a server, with SSL support. I add async_read_some() function in handshake handler and send handler. Which receiving is OK if I send something to clients, but I can't keep receiving after I stop sending things to client. So I am wondering how can I keep receiving, I know there must be a way to make it, I am new to Asio, can someone help, thanks in advance.
------------------ I won't go
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
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.
it works ! thanks a lot.
------------------ Original ------------------
From: "Gavin Lambert";
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@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (4)
-
Gavin Lambert
-
Radu Andrei Nedelcu
-
Richard Hodges
-
刘焕杰