Boost logo

Boost :

Subject: Re: [boost] async_read SEGFAULT
From: Richard Hodges (hodges.r_at_[hidden])
Date: 2019-01-07 10:23:48

Yes, you will need separate buffers for read and write. Even without
multi-threading, since it's entirely possible to have an async_read in
progress at the same time as an async_write on the same socket.

For multiple threads, host a
`asio::strand<asio::io_context::executor_type>` in each io object (server,
connection, client).

Bind all the class's handlers to that strand (see my example above). The
strand behaves like an extremely efficient mutex, with respect to handler
invocation, for your object.

On Mon, 7 Jan 2019 at 17:11, hh h via Boost <boost_at_[hidden]> wrote:

> I currently use a fixed size of array char buffer[MAX_SIZE] as a life
> time buffer attached to the class running on async_read, I think that
> was your point it should live as long as the socket lives. I think it
> should be fine for running a single thread, for multiple threads it
> might cause issues.
> Anyway, I am going to run a single thread, to use two static life time
> buffers, one for async_read, one for async_write.
> Thanks Richard.
> _______________________________________________
> Unsubscribe & other changes:

Richard Hodges
office: +442032898513
home: +376841522
mobile: +376380212 (this will be *expensive* outside Andorra!)
skype: madmongo
facebook: hodges.r

Boost list run by bdawes at, gregod at, cpdaniel at, john at