Boost logo

Boost :

Subject: [boost] [asio] ip::tcp::socket thread safety
From: Gaetano Mendola (mendola_at_[hidden])
Date: 2012-04-02 11:07:54


Hi all,
reading the manual I see that ip::tcp::socket thread safety on shared object is not safe.

In my application I'm using:

ip::tcp::socket::async_connect
boost::asio::async_read( ip::tcp::socket , ...)

the application queue an async_read or an async_connect inside
the receiving handler (in case of error it retry the connection).

>From an external thread (to stop the reception) I perform a:

ip::tcp::socket::shutdown
ip::tcp::socket::close

do I have realy to synchronize the async_connect/async_read with
shutdown/close ?

Using a mutex to protect those calls seems an overkill, may be shutdown
and close can be called in concurrency with async_connect/async_read and the
documentation is just conservative?

Regards
Gaetano Mendola


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk