0
votes

boost::system::error_code error; const boost::asio::ip::tcp::endpoint endpoint = socket.remote_endpoint(error);

I'm using this code to get the IP from the socket and i want to know since this code is called from multiple threads if it need a mutex lock. The socket object is used by others threads in calls to async_write, async_read, socket.shutdown and socket.close. Currently there is a mutex lock around that call which is used everytime a call is made using the socket object but i want to remove the mutex lock so there is less multi-thread interference.

1

1 Answers

0
votes

Basically asio library is not that pefect when it comes to protecting the socket object from multiple thread so i recommend to protect the call to socket.remote_endpoint since there is a risk socket.shutdown is called at the same time = crash.