c->add_callback(new_connection,bind(&command_client::read_hello, boost::ref(*this)));
// don't expect hello from an always closed connection (like dummy_client_connection)
- if (!c->is_closed())
- read_hello();
+ if (!is_connection_closed())
+ {
+ try
+ {
+ read_hello();
+ }
+ catch (t2n_communication_error &e)
+ {
+ c->close();
+
+ // store a copy of the exception that you can find out details about the error later
+ std::auto_ptr<t2n_exception> tmp(e.clone());
+ constructorException=tmp;
+ }
+ catch (...)
+ {
+ throw;
+ }
+ }
}
/** @brief replace the connection currently in use with a new one
command_container cc(cmd);
boost::archive::binary_oarchive oa(ofs);
+ if (is_connection_closed())
+ throw t2n_transfer_error("connection to server is closed");
+
try
{
oa << cc;