FACT++  1.0
test_client_many.c
Go to the documentation of this file.
1 
2 #include <dic.h>
3 #include <time.h>
4 
5 char str[80];
6 char str_res[10][80];
7 char client_str[80];
8 int no_link = -1;
9 float no_link_float = -1.0;
10 char buff[80];
11 
12 typedef struct {
13  int i;
14  int j;
15  int k;
16  double d;
17  short s;
18  char c;
19  short t;
20  float f;
21  char str[20];
22 }TT;
23 
24 TT t;
25 /*
26 void big_rout( tag, buf, size )
27 int *buf;
28 int *tag, *size;
29 {
30 
31  printf("Received %d for TestMem\n", *buf);
32 }
33 */
34 void rout_many( tag, buf, size )
35 float *buf;
36 int *tag, *size;
37 {
38  if(*tag == 50000)
39  {
41  printf("Received %f for service %d\n", *buf, *tag);
42  }
43 }
44 
45 void rout( tag, buf, size )
46 char *buf;
47 int *tag, *size;
48 {
49  int conn_id;
50  char server[128];
51 
52  if(*tag == 1100)
53  {
54  printf("Received ONCE_ONLY : %s\n",buff);
55  return;
56  }
57  if(*tag == 1200)
58  {
59  char node[128], str[256];
60  int secs, millis;
61  time_t tsecs;
62 
63  dic_get_dns_node(node);
64  printf("DNS node = %s\n",node);
65  printf("size = %d\n",*size);
66  memcpy(&t, buf, *size);
67  printf("t.i = %d, t.d = %2.2f, t.s = %d, t.c = %c, t.f = %2.2f, t.str = %s\n",
68  t.i,t.d,t.s,t.c,t.f,t.str);
69  dic_get_timestamp(0, &secs, &millis);
70  tsecs = secs;
71  my_ctime(&tsecs, str, 128);
72  str[strlen(str)-1] = '\0';
73  printf("timestamp = %s.%d\n",str,millis);
74 
75  return;
76  }
77  else
78  printf("%s Received %s for Service%03d\n",client_str,buf, *tag);
79 
80 /*
81  if(conn_id = dic_get_server(server))
82  printf("received from %d, %s\n",conn_id, server);
83 */
84 
85 }
86 
87 main(argc,argv)
88 int argc;
89 char **argv;
90 {
91  int i, *ptr;
92  char aux[80];
93  int id = 123;
94 
95 /*
96  dic_set_debug_on();
97 */
98 /*
99  dic_set_dns_node("pclhcb99.cern.ch");
100 */
101 
102  sprintf(str,"%s/SET_EXIT_HANDLER",argv[2]);
103  dic_cmnd_service(str, &id, 4);
104  dic_get_id(aux);
105  printf("%s\n",aux);
106  strcpy(client_str,argv[1]);
107 /*
108  for(i = 0; i< 10; i++)
109  {
110  sprintf(str,"%s/Service_%03d",argv[2],i);
111  dic_info_service( str, TIMED, 10, 0, 0, rout, i,
112  "No Link", 8 );
113  }
114 
115  sprintf(aux,"%s/TEST_SWAP",argv[2]);
116  dic_info_service_stamped( aux, TIMED, 5, 0, 0, rout, 1200,
117  &no_link, 4 );
118 */
119 /*
120  sprintf(aux,"%s/TestMem",argv[2]);
121  dic_info_service( aux, MONITORED, 0, 0, 0, big_rout, 0,
122  &no_link, 4 );
123 */
124 
125  for(i = 0; i< 100000; i++)
126  {
127  sprintf(aux,"%s/ServiceMany%05d",argv[2],i);
128  dic_info_service( aux, MONITORED, 60, 0, 0, rout_many, i,
129  &no_link_float, 4 );
130  }
131 
132  sprintf(aux,"%s/TEST_CMD",argv[2]);
133  while(1)
134  {
135  int index = 0;
136  sleep(10);
137 /*
138  printf("Sending Command, size = %d, i = %d\n",sizeof(t), t.i);
139  dic_cmnd_service(aux,&t,sizeof(t));
140 */
141  }
142 }
void rout_many(int *tag, float *buf, int *size)
#define my_ctime(t, str, size)
Definition: dim_common.h:275
Definition: dns.c:26
char str[20]
Definition: test_client.c:23
int no_link
main(int argc, char **argv)
float f
Definition: test_client.c:22
unsigned dic_info_service(char *serv_name, int req_type, int req_timeout, void *serv_address, int serv_size, void(*usr_routine)(), dim_long tag, void *fill_addr, int fill_size)
Definition: dic.c:601
int dic_get_id(char *name)
Definition: dic.c:2062
int i
Definition: db_dim_client.c:21
#define MONITORED
Definition: dim_common.h:9
char str[80]
Definition: test_client.c:14
char buff[80]
short s
Definition: test_client.c:19
void rout(int *tag, char *buf, int *size)
TT t
int dic_cmnd_service(char *serv_name, void *serv_address, int serv_size)
Definition: dic.c:694
int dic_get_dns_node(char *node)
Definition: open_dns.c:81
char str_res[10][80]
char c
Definition: test_client.c:20
int i
Definition: test_client.c:15
int size
Definition: db_dim_server.c:17
double d
Definition: test_client.c:18
void dim_print_date_time()
Definition: utilities.c:134
float no_link_float
sprintf(name1,"NewService%d", i)
char client_str[80]
int dic_get_timestamp(unsigned serv_id, int *secs, int *milisecs)
Definition: dic.c:984