X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=src%2Fsocket_wrapper.cpp;h=7bbe20c09cd6e0750619c2e12f6dbbde8493b90d;hp=ac88144433c32930c08be2a92b3e89f3f0602406;hb=238ad35f4e3b6516d4ba7611b540a0edeea71427;hpb=fb3345ada7ea94225b78994fd50e3de693a2a3d5 diff --git a/src/socket_wrapper.cpp b/src/socket_wrapper.cpp index ac88144..7bbe20c 100644 --- a/src/socket_wrapper.cpp +++ b/src/socket_wrapper.cpp @@ -25,6 +25,17 @@ namespace libt2n { +/// set logging for coming and current connections +void BasicSocketWrapper::set_logging(std::ostream *_logstream, log_level_values _log_level) +{ + ConnectionWrapper::set_logging(_logstream,_log_level); + + if (connection_established()) + get_connection()->set_logging(_logstream,_log_level); +} + + +/// return active connection, create new tcp or unix connection if not existing client_connection* BasicSocketWrapper::get_connection(void) { if (c.get() == NULL) @@ -40,6 +51,8 @@ client_connection* BasicSocketWrapper::get_connection(void) return c.get(); } +/// try to reconnect max_retries time if we encounter a t2n_communication_error +/// during execution of the command bool ReconnectSocketWrapper::handle(command_client* stubBase, boost::function< void() > f) { int tries=0; @@ -82,6 +95,7 @@ bool ReconnectSocketWrapper::handle(command_client* stubBase, boost::function< v return false; } +/// return active connection, return a dummy-connection if we can't establish one client_connection* ReconnectIgnoreFailureSocketWrapper::get_connection(void) { client_connection* tmp=BasicSocketWrapper::get_connection(); @@ -97,6 +111,7 @@ client_connection* ReconnectIgnoreFailureSocketWrapper::get_connection(void) return tmp; } +/// try to execute the command, may ignore the command if server not available bool ReconnectIgnoreFailureSocketWrapper::handle(command_client* stubBase, boost::function< void() > f) { if (!connection_established())