|
Boost Users : |
Subject: [Boost-users] [ASIO] Thread safety of socket.write_some & socket.read_some
From: James12 (james791d_at_[hidden])
Date: 2008-10-29 08:50:02
Hi,
I'm a beginner in using boost asio library (and coding c++ too :).
I am currently trying to code a simple application that handles some
communication with a server through TCP/IP connection.
My I/O Class has two threads that use synchronous socket operations on the
same socket (which is a member of the class)
Main thread:
CApplication::Close()
- socket.close()
CApplication::Open()
- socket.open(boost::asio::ip::tcp::v4());
- socket.write_some(boost::asio::buffer(initial_command));
- socket.read_some(boost::asio::buffer(initial_command_reply));
CApplication::Write(data from another class)
- m_Socket.write_some
Workerthread:
CApplication::thread_Run()
do
{
- socket.read_some(boost::asio::buffer((void *)&character, 1));
- package bytes to messages and pass them on to another class
}
while (!bClosed)
My question is that is it safe to call write_some and read_some from
different threads without synchronization.
The application is now working w/o problems but I need to be sure that this
is a safe way to do this before continuing development.
Thanks for your reply,
James
-- View this message in context: http://www.nabble.com/-ASIO--Thread-safety-of-socket.write_some---socket.read_some-tp20222810p20222810.html Sent from the Boost - Users mailing list archive at Nabble.com.
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