4

I have two threads, one sending and another receiving data via TCP socket. I use boost::asio::read() and boost::asio::write() for reading and writing. My question is do I have to guard the access to socket object during read and write operation?

The other case would be what if I have two threads both writing using the same socket object?

Sam Miller
  • 23,808
  • 4
  • 67
  • 87
dev
  • 2,180
  • 2
  • 30
  • 46

1 Answers1

5

The socket is not thread safe when shared between two or more threads. For more information look at the Boost.Asio documentation.

murrekatt
  • 5,961
  • 5
  • 39
  • 63