cleanup
[libt2n] / examples / minimalistic-server.cpp
1 /***************************************************************************
2  *   Copyright (C) 2004 by Intra2net AG                                    *
3  *   info@intra2net.com                                                    *
4  *                                                                         *
5  ***************************************************************************/
6
7 #include <string>
8 #include "minimalistic-stub.hxx"
9
10 #include <socket_server.hxx>
11 #include <command_server.hxx>
12
13 using namespace std;
14
15 LIBT2N_SET_DEFAULTGROUP(example);
16
17 LIBT2N_EXPORT std::string testfunc(const string& str) 
18 {
19     string ret;
20     if (str=="throw")
21         throw libt2n::t2n_runtime_error("throw me around");
22     if (str=="big")
23         ret.insert(0,100*1024,'x');
24     else
25         ret=str+", testfunc() was here";
26     return ret;
27 }
28
29 using namespace libt2n;
30
31 int main(int argc, char** argv) {
32   extended_type_info_test();
33
34   socket_server ss("./socket");
35   group_command_server<cmd_group_example> cs(ss);
36
37   // handle requests (without timeout)
38   while(true)
39     cs.handle();
40
41   return 0;
42 }