FACT++  1.0
db_dim_client.c
Go to the documentation of this file.
1 // db_dim_client.c : Defines the entry point for the console application.
2 //
3 // Dietrich Beck
4 //
5 // This is a very simple DIM service. It listens to a DIM service
6 // "SERV_BY_BUFFER" via a callback routine. Each time THIS client
7 // receives a service, it sends a new command to the DIM server.
8 
9 #include <stdio.h>
10 #include <dic.h>
11 
12 #define BUFFSIZE 10000000
13 
16 char message[1024];
17 int no_link = -1;
18 int version;
19 int counter;
21 int i;
22 unsigned service_id;
23 
24 serv_received(tag,address,size)
25 int *tag;
26 char *address;
27 int *size;
28 {
29  for (i=0;i<BUFFSIZE;i++) buff[i] = buffer[i]; //copy data to do something useful
30  counter++;
31  sprintf(message, "service received %d\n", counter);
32  printf(message);
33 }
34 
35 void main(int argc, char* argv[])
36 {
37 
38  //service_id = dic_info_service("testBuffer",MONITORED,0,0,0,serv_received,0,&no_link,4);
39 // printf("registering to service\n");
40 // counter = 0;
41 // service_id = dic_info_service("testBuffer",MONITORED,0,0,0,serv_received,0,&no_link,4);
42  while(1)
43  {
44  printf("registering to service\n");
45  counter = 0;
46  service_id = dic_info_service("testBuffer",MONITORED,0,0,0,serv_received,0,&no_link,4);
47  sleep(1);
48  printf("releasing service\n");
50  printf("released service\n");
51  sleep(1);
52  //sprintf(message, "%s", dic_get_error_services());
53  }
54 }
55 
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
unsigned service_id
Definition: db_dim_client.c:22
int i
Definition: db_dim_client.c:21
#define MONITORED
Definition: dim_common.h:9
#define BUFFSIZE
Definition: db_dim_client.c:12
int buffer[BUFFSIZE]
Definition: db_dim_client.c:14
int size
Definition: db_dim_server.c:17
void main(int argc, char *argv[])
Definition: db_dim_client.c:35
int counter
Definition: db_dim_client.c:19
int version
Definition: db_dim_client.c:18
int buff[BUFFSIZE]
Definition: db_dim_client.c:15
void dic_release_service(unsigned service_id)
Definition: dic.c:1025
serv_received(int *tag, char *address, int *size)
Definition: db_dim_client.c:24
sprintf(name1,"NewService%d", i)
int lastValue
Definition: db_dim_client.c:20
char message[1024]
Definition: db_dim_client.c:16
int no_link
Definition: db_dim_client.c:17