Boost logo

Boost Users :

Subject: Re: [Boost-users] boost concurrent write/read
From: Rutger ter Borg (rutger_at_[hidden])
Date: 2011-03-09 06:31:49


On 03/09/2011 12:14 PM, Marco Piacentini wrote:
> I have a simple TCP multiprocess server...inside each child server(each
> of one handles distincted connection), I call a list of
> operation...suppose the following:
>
>
> socket.async_read_some(....); //receive a client request
> socket.async_write_some(...); //respond to client request
>
> socket.async_write_some(...); //independently of the client request,
> send something to the client
>
> Have I use strand,or this situation doesn't cause problems?
> I don't use thread...
> thanks!!!

Without threads, you don't need a strand (the strand is implicit).

But, even without threads, you still would need to make sure that the
read or write operation is completed before issueing your next request. So,

socket.async_read(...); // OK
socket.async_write( ... ); // OK
socket.async_read( ... ); // Potential error: 1st async_read may be
still in progress

Regards,

Rutger


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