DemoClients.cc File Reference

#include "TROOT.h"
#include "TSystem.h"
#include "MessageService/MsgService.h"
#include "Dispatcher/DDS.h"
#include "Dispatcher/DDSClient.h"

Go to the source code of this file.

Functions

TROOT root ("DemoClient","MINOS Data Dispatcher System Demo Client")
 CVSID ("$Id: DemoClients.cc,v 1.4 2003/09/30 19:49:38 kasahara Exp $")
int main (int argc, char **argv)

Function Documentation

CVSID ( "$Id: DemoClients.  cc,
v 1.4 2003/09/30 19:49:38 kasahara Exp $"   
)
int main ( int  argc,
char **  argv 
)

Definition at line 27 of file DemoClients.cc.

References gSystem(), Msg::kInfo, Munits::ms, and MSGSTREAM.

00027                                 {
00028 
00029   MsgStream& ms = MSGSTREAM("DDS",Msg::kInfo);
00030 
00031   ms << "This demo will attempt to set up 11 client connections\n"
00032      << "with the dispatcher server.  The first 10 will succeed.  The\n"
00033      << "11th will be rejected with a server 'Saturated' error message.\n"
00034      << "(The saturation level of the server is set by the kMaxChild\n"
00035      << "constant in the DDSParentServer class.  It has arbitrarily\n"
00036      << "been set to 10 for now.)" << endl;
00037 
00038   const char* serverhostname;
00039   if (argc > 1) {
00040     serverhostname = argv[1];
00041     ms << "The user has requested that the client will attempt to connect\n"
00042        << "to a parent server running on host " << serverhostname 
00043        << ".\n" << endl;
00044   }
00045   else {
00046     // Determine the host name of the current machine
00047     serverhostname = gSystem -> HostName();
00048     ms << "Since the user has not specified the host of the parent server\n"          << "as an argument to this demo, the default is to assume that the\n"
00049        << "parent server runs on the local host " << serverhostname 
00050        << ".\n" << endl;
00051   }
00052 
00053   const Int_t nclient = 11;
00054   // Create an array of DDSClient pointers to keep track of client connections
00055   DDSClient* ddsclient[nclient];
00056 
00057   for (Int_t ic= 0; ic < nclient; ic++) {
00058     // Create a DDSClient object connected to the DDS server running on 
00059     // node kasahara.hep.umn.edu and port 9090.
00060     ddsclient[ic] = new DDSClient(serverhostname,9090);
00061 
00062     // Check validity of connected socket before using it
00063     if (! ddsclient[ic]->IsValid() ) {
00064       ms << "Error in creation of socket connected to server for client " 
00065          << ic + 1 << ".\n" << endl;
00066       delete ddsclient[ic]; ddsclient[ic] = 0;
00067     }
00068     else {
00069       ms << "Successfully connected to dispatcher server for client " 
00070          << ic + 1 << "." << endl;
00071       ms << ddsclient[ic] << endl;
00072     }
00073   }
00074 
00075   // Normally subscribe and execute entry retrieval loop here.
00076   ms << "The demo will now shutdown the connected clients."
00077      << endl; 
00078 
00079   for (Int_t ic = 0; ic < nclient; ic++) {
00080     if ( ddsclient[ic] ) {
00081       ms << "Sending shutdown message to server for client " << ic + 1
00082          << "." << endl;
00083       ddsclient[ic] -> Shutdown();
00084       delete ddsclient[ic]; ddsclient[ic] = 0;
00085     }
00086   }
00087 
00088   return 0;
00089 
00090 }

TROOT root ( "DemoClient"  ,
"MINOS Data Dispatcher System Demo Client"   
)

Generated on 16 Apr 2018 for loon by  doxygen 1.6.1