added test using own class as argument
[libt2n] / examples / minimalistic-server.cpp
CommitLineData
db49c2f9
JT
1/***************************************************************************
2 * Copyright (C) 2004 by Intra2net AG *
3 * info@intra2net.com *
4 * *
5 ***************************************************************************/
6
7#include <string>
db49c2f9
JT
8#include "minimalistic-stub.hxx"
9
10#include <socket_server.hxx>
11#include <command_server.hxx>
12
13using namespace std;
14
4cae8ac9 15LIBT2N_SET_DEFAULTGROUP(example);
ec979c57 16
4cae8ac9 17LIBT2N_EXPORT std::string testfunc(const string& str)
db49c2f9
JT
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
29using namespace libt2n;
30
31int 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}