1 // for a wrapped socket connection
2 #include <socket_wrapper.hxx>
4 // include generated library header
5 #include "t2nexample_client.hxx"
7 // define a type for more conveniant access
8 typedef libt2n::T2nSingletonWrapper<cmd_group_t2nexample_client> wraptype;
10 // static object which keeps the wrapper-singleton
12 std::auto_ptr<wraptype> wraptype::SingletonObject = std::auto_ptr<wraptype>();
14 // static object which keeps the connection
16 std::auto_ptr<libt2n::ConnectionWrapper> wraptype::WrappedConnection =
17 std::auto_ptr<libt2n::ConnectionWrapper>();
19 int main(int argc, char** argv)
21 // tell the client-wrapper how to contact the server if a connection is requested
22 wraptype::set_connection(std::auto_ptr<libt2n::ConnectionWrapper>
23 (new libt2n::ReconnectSocketWrapper("./socket")));
25 // execute a function via t2n. The wrapper will open a connection to the server if none
26 // exists or try to reconnect if the existing one doesn't answer
27 std::cout << t2n_exec(&cmd_group_t2nexample_client::testfunc)("hello") << std::endl;