FACT++  1.0
rpc_server.cxx
Go to the documentation of this file.
1 #include <dis.hxx>
2 #include <dic.hxx>
3 #include <iostream>
4 using namespace std;
5 #include <stdio.h>
6 
7 class RpcInt : public DimRpc
8 {
9  int val;
10 
11  void rpcHandler()
12  {
13  val = getInt();
15  printf("Got RPC %d\n", val);
16  val++;
17 // usleep(700000);
19  printf("Answering RPC %d\n", val);
20  setData(val);
21  }
22 public:
23  RpcInt(const char *name): DimRpc(name,"I","I") {val = 0;};
24 };
25 
26 typedef struct tst{
27  char str1[16];
28  int ints[5];
29  char str2[18];
30  float floats[4];
31  int int1;
32  float floats1[16];
33 } MyStruct;
34 
35 typedef struct jeffIn{
36  char c1;
37  char c2;
38  char c3;
39  char str[3000];
40 }JeffIn;
41 
42 typedef struct jeffOut{
43  int i1;
44  char c1;
45  char str[3000];
46 }JeffOut;
47 
48 class RpcStruct : public DimRpc
49 {
51 
52  void rpcHandler()
53  {
54  val = (MyStruct *)getData();
55  val->int1++;
56  setData(val, sizeof(MyStruct));
57  }
58 public:
59  RpcStruct(const char *name): DimRpc(name,"C:16;I:5;C:18;F:4;I:1;F:16",
60  "C:16;I:5;C:18;F:4;I:1;F:16") {val = 0;};
61 };
62 
63 class JeffRpcStruct : public DimRpc
64 {
67  int counter;
68 
69  void rpcHandler()
70  {
71  pin = (JeffIn *)getData();
72  pout.i1 = counter++;
73  pout.c1 = pin->c1;
74  strcpy(pout.str,pin->str);
75  setData(&pout, (int)strlen(pout.str)+1+5);
76  }
77 public:
78  JeffRpcStruct(const char *name): DimRpc(name,"C:1;C:1;C:1;C",
79  "I:1;C:1;C") {counter = 0;};
80 };
81 
82 int main()
83 {
84  RpcInt myRpcInt("TESTRPC/INT");
85  RpcInt *myRpcP;
86  RpcStruct myRpcStruct("TESTRPC/STRUCT");
87  JeffRpcStruct jeffRpcStruct("TESTJEFF");
88  int i;
89  char name[64];
90 
91  for(i = 0; i < 10; i++)
92  {
93  sprintf(name,"TESTRPC%d/INT",i);
94  myRpcP = new RpcInt(name);
95  }
96  DimServer::start("TESTRPC");
97  while(1)
98  pause();
99  return 0;
100 }
Definition: dis.hxx:301
void rpcHandler()
Definition: rpc_server.cxx:52
JeffRpcStruct(const char *name)
Definition: rpc_server.cxx:78
int i
Definition: db_dim_client.c:21
char str[80]
Definition: test_client.c:7
char c2
Definition: rpc_server.cxx:37
STL namespace.
char str[3000]
Definition: rpc_server.cxx:45
struct tst MyStruct
int val
Definition: rpc_server.cxx:9
struct jeffOut JeffOut
char c1
Definition: rpc_server.cxx:44
char str[3000]
Definition: rpc_server.cxx:39
void rpcHandler()
Definition: rpc_server.cxx:11
char c3
Definition: rpc_server.cxx:38
MyStruct * val
Definition: rpc_server.cxx:50
int main()
Definition: rpc_server.cxx:82
void rpcHandler()
Definition: rpc_server.cxx:69
JeffIn * pin
Definition: rpc_server.cxx:65
RpcStruct(const char *name)
Definition: rpc_server.cxx:59
static void start()
Definition: discpp.cxx:512
int int1
Definition: rpc_client.cxx:21
JeffOut pout
Definition: rpc_server.cxx:66
void dim_print_date_time()
Definition: utilities.c:134
char c1
Definition: rpc_server.cxx:36
struct jeffIn JeffIn
RpcInt(const char *name)
Definition: rpc_server.cxx:23
sprintf(name1,"NewService%d", i)