"Igor R"
Does all of that sound about right?
Yes, that's exactly the way it's done in the examples.
Great, thanks!
The close method calls "is_open" to determine if the socket has already been closed, and if it is not asks the OS to close it.
It looks to me like this is not done in a threadsafe way.
Right, you should post closing to the io_service thread, like this:
Ah, I see, thanks for the sample code! I'm not sure I understand exactly what makes this threadsafe, though. It seems like if my reader callback and writer callback are running simultaneously, and both decide to close the connection, they will post two close requests to io_service. If those requests are scheduled on two different worker threads, they could execute simultaneously, and still cause problems.
void my_connection::do_close() { boost::system::error_code err; socket_.close(err); }
Maybe I should just hold a lock in do_close? That seems like it would solve the problem. Thanks again for the help! -----Scott.