AlcapDAQ  1
client.cc
Go to the documentation of this file.
1 {
2  char host_str[100] = "sc32";
3  int port = 9090;
4  TSocket *s = new TSocket(host_str,port);
5  if (!s->IsValid())
6  {
7  printf("Unable to establish connection to %s at port %d\n", host_str, port);
8  exit(1);
9  }
10 
11  char ver[100];
12  s->Recv(ver,100);
13  printf("Online analyzer version: %s\n", ver);
14 
15  char req[256];
16  TMessage *msg;
17 
18  printf("Object listing ...\n");
19  sprintf(req,"LIST");
20  s->Send(req); // send request
21  s->Recv(msg); // receive a TMessage from the server
22  TObjArray *names = (TObjArray*)msg->ReadObject(msg->GetClass());
23  for (int i = 0; i < names.GetEntries(); ++i)
24  {
25  TObjString *histname = names.At(i);
26  //printf("object %d: %s\n", i, histname->GetString().Data());
27  // Get the histogram
28  sprintf(req,"GET %s", histname->GetString().Data());
29  s->Send(req);
30  s->Recv(msg);
31  TH1 *hist = (TH1*) msg->ReadObject(msg->GetClass());
32  hist->Print();
33  hist->Draw();
34  }
35 }