|
Boost Users : |
From: Richard Hodges (hodges.r_at_[hidden])
Date: 2020-12-30 18:11:49
On Wed, 30 Dec 2020 at 15:47, Fariya F via Boost-users <
boost-users_at_[hidden]> wrote:
> Hi,
>
> Thanks. A couple of more questions:
> a) Could you help me with a sample code which handles shutdown gracefully
> (async shutdown + timer) for iterative servers?
> b) I have also seen issues where the code hangs just like the shutdown()
> when I invoke socket_.lowest_layer().cancel(). Is this expected?
> c) Is this what is the code to be put in the async shutdown handler?
> socket_.lowest_layer().close(ignored_ec);
>
a) Funnily enough I answered a similar question today on timed asio udp
reception, but it's the same principle.
That answer is here:
https://godbolt.org/z/x7hsd5
In this case you'd substitute the async_receive with stream.async_shutdown
and you'd cancel() the lowest_layer
b) It depends what was pending on the lowest layer. In general I would not
expect to see anything hang in an asynchronous system. Could it be that you
are mixing sync and async in more than one place?
c) yes, that should do it.
>
> Regards,
> Fariya
>
> On Wed, Dec 30, 2020 at 8:04 PM Vinnie Falco <vinnie.falco_at_[hidden]>
> wrote:
>
>> On Wed, Dec 30, 2020 at 6:27 AM Fariya F via Boost-users
>> <boost-users_at_[hidden]> wrote:
>> > I see that the call to ssl socket member function shutdown() blocks
>> sometimes forever
>>
>> You are mixing synchronous and asynchronous operations on the same
>> socket, which is generally disallowed. Use async_shutdown instead, and
>> also use a timer to close the socket after some time period (say, 30
>> seconds).
>>
>> Regards
>>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>
-- Richard Hodges hodges.r_at_[hidden] office: +442032898513 home: +376841522 mobile: +376380212
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