Commit | Line | Data |
---|---|---|
208db683 JT |
1 | // for socket_client_connection |
2 | #include <socket_client.hxx> | |
3 | ||
4 | // include generated library header | |
5 | #include "t2nexample_client.hxx" | |
6 | ||
7 | int main(int argc, char** argv) | |
8 | { | |
c7857475 GE |
9 | // use a local socket (a.k.a "unix domain socket") |
10 | // if you want to connect to a tcp/ip server you pass the port and server name to the constructor | |
11 | libt2n::socket_client_connection sc("./socket"); | |
12 | // this generated class has a method for each of our exported procedures | |
13 | cmd_group_t2nexample_client cc(sc); | |
208db683 | 14 | |
c7857475 | 15 | bool throwok=false; |
208db683 | 16 | |
c7857475 GE |
17 | // exceptions are passed back to the client transparently |
18 | try | |
19 | { | |
20 | // call the remote procedure (we pass "throw" to cause a exception to be thrown) | |
21 | cc.testfunc("throw"); | |
22 | } | |
23 | catch(libt2n::t2n_runtime_error &e) | |
24 | { | |
25 | throwok=(std::string(e.what())=="throw me around"); | |
26 | } | |
208db683 | 27 | |
c7857475 GE |
28 | // call remote procedure and check the return value is correct |
29 | return ( throwok && ( cc.testfunc("hello") == "hello, testfunc() was here" ) ) | |
30 | ? EXIT_SUCCESS : EXIT_FAILURE; | |
208db683 | 31 | } |