00001 #include "TROOT.h"
00002 #include "TSystem.h"
00003 #include "MessageService/MsgService.h"
00004 #include "Dispatcher/DDS.h"
00005 #include "Dispatcher/DDSClient.h"
00006
00007 TROOT root("DemoClient","MINOS Data Dispatcher System Demo Client");
00008 CVSID("$Id: DemoClients.cc,v 1.4 2003/09/30 19:49:38 kasahara Exp $");
00009
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00026
00027 int main(int argc, char **argv) {
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
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
00055 DDSClient* ddsclient[nclient];
00056
00057 for (Int_t ic= 0; ic < nclient; ic++) {
00058
00059
00060 ddsclient[ic] = new DDSClient(serverhostname,9090);
00061
00062
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
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 }
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108