Commit | Line | Data |
---|---|---|
393e7b70 GE |
1 | // for a wrapped socket connection |
2 | #include <socket_wrapper.hxx> | |
3 | ||
4 | // include generated library header | |
5 | #include "t2nexample_client.hxx" | |
6 | ||
7 | // define a type for more conveniant access | |
8 | typedef libt2n::T2nSingletonWrapper<cmd_group_t2nexample_client> wraptype; | |
9 | ||
10 | // static object which keeps the wrapper-singleton | |
11 | template<> | |
12 | std::auto_ptr<wraptype> wraptype::SingletonObject = std::auto_ptr<wraptype>(); | |
13 | ||
14 | // static object which keeps the connection | |
15 | template<> | |
16 | std::auto_ptr<libt2n::ConnectionWrapper> wraptype::WrappedConnection = | |
17 | std::auto_ptr<libt2n::ConnectionWrapper>(); | |
18 | ||
19 | int main(int argc, char** argv) | |
20 | { | |
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"))); | |
24 | ||
393e7b70 GE |
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 | |
d7091a50 | 27 | std::cout << t2n_exec(&cmd_group_t2nexample_client::testfunc)("hello") << std::endl; |
393e7b70 GE |
28 | |
29 | return EXIT_SUCCESS; | |
30 | } |