Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNnet_rpc_c.hxx

00001 /******************************************************************
00002  * CAVERNsoft
00003  * Copyright (C) 1994-2000 Electronic Visualization Laboratory,
00004  * all rights reserved
00005  * By Jason Leigh, Yong-joo Cho, Naveen Krishnaprasad, Chris Scharver,
00006  * Stuart Bailey, Atul Nayak, Shalini Venkataraman
00007  * University of Illinois at Chicago
00008  * 
00009  * This publication and its text and code may not be copied for commercial 
00010  * use without the express written permission of the University of Illinois
00011  * at Chicago.
00012  * The contributors disclaim any representation of warranty: use this
00013  * code at your own risk.
00014  * Direct questions, comments etc to cavern@evl.uic.edu
00015  ******************************************************************/
00016 
00017 #ifndef _CAVERNPLUS_RPC_C
00018 #define _CAVERNPLUS_RPC_C
00019 
00020 #include "CAVERN.hxx"
00021 class CAVERNnet_rpcHandle_c
00022 {
00023 public:
00024         char *rpcName;
00025         int (*callback) (char* indata, int inlen, char** outdata, int *outlen);
00026         CAVERNnet_rpcHandle_c();
00027 };
00028 
00029 
00034 class CAVERNnet_rpcManager_c
00035 {
00036 public:
00038 
00041         static const int DEFAULT_RPCS/* = 64*/;
00042 
00045         static const int DEFAULT_PORT/* = 9000*/;
00046 
00048         static const int OK/* = 1*/;
00049 
00051         static const int CANNOT_MANAGE_ANY_MORE/* = 4*/;
00052 
00054         static const int RPC_NOT_FOUND/* = 3*/;
00055 
00057         static const int MEM_ALLOC_ERR/* = 2*/;
00058 
00060         static const int FAILED/* = 0*/;
00062 
00063         CAVERNnet_rpcManager_c();
00064 
00070         int init(int maxRPCs = CAVERNnet_rpcManager_c :: DEFAULT_RPCS,
00071                  int inPort = CAVERNnet_rpcManager_c :: DEFAULT_PORT);
00072 
00078         int manage(char* procedureName, int (*callback) (char *indata, int inlen,
00079                                                          char **outdata, int *outlen));
00080 
00084         int unmanage(char* procedureName);
00085 
00088         void process();
00089 
00090 
00091     //for performance monitoring
00092 
00104     void showStats(char* streamInfo, char* comment);
00105 
00122     int logStats(char* streamInfo, char* comment, FILE* filePtr);
00123 
00138     int sendStats(char* streamInfo, char* comment);
00139 
00154     int initSendStats(char* monitorClientIP, int port = PERF_DAEMON_DEFAULT_PORT);
00155     
00160     void exitSendStats();
00161 
00162 private:
00163         int maxNumRPCs;
00164         CAVERNnet_rpcHandle_c *handleList;
00165         CAVERNnet_tcpServer_c server;
00166 
00167         // Reply to an RPC. Returns OK or FAILED
00168         int replyRPC(CAVERNnet_tcpClient_c *client, char* returnValue, int returnSize);
00169 
00170         // Find an RPC in the manager list
00171         CAVERNnet_rpcHandle_c *findRPC(char*);
00172 
00173         // Handle incoming RPC request. Returns OK or FAILED
00174         int handleRPC(CAVERNnet_tcpClient_c *client);
00175 
00176     //For performance monitoring
00177     CAVERNnet_perfMonitor_c pmonitor;
00178 };
00179 
00182 class CAVERNnet_rpcCaller_c
00183 {
00184 public:
00186 
00187         static const int NEVER_TIME_OUT/* = CAVERNnet_tcpClient_c::NO_TIME_OUT*/;
00189         static const int FAILED/* = 0*/;
00190 
00192         static const int OK/* = 1*/;
00193 
00195         static const int MEM_ALLOC_ERR/* = 2*/;
00197 
00204         int init(char *remoteProcedureName, char* ipAddress, int destPort=CAVERNnet_rpcManager_c::DEFAULT_PORT);
00205 
00213         int call(char *outdata, int outlen, char** retdata, int *retlen);
00214 
00220         int call1way(char *outdata, int outlen);
00221 
00225         void setTimeOut(int timeout = CAVERNnet_rpcCaller_c::NEVER_TIME_OUT) {itsTimeOut = timeout;}
00226 
00227         CAVERNnet_rpcCaller_c();
00228 
00229     //for performance monitoring
00230 
00242     void showStats(char* streamInfo, char* comment);
00243     
00260     int logStats(char* streamInfo, char* comment, FILE* filePtr);
00261 
00276     int sendStats(char* streamInfo, char* comment);
00277 
00290     int initSendStats(char* monitorClientIP, int port = PERF_DAEMON_DEFAULT_PORT);
00291     
00295     void exitSendStats();
00296 
00297 private:
00298         char *rpcName;
00299         char ipAddress[256];
00300         int destinationPort;
00301         int itsTimeOut;
00302     //For performance monitoring
00303     CAVERNnet_perfMonitor_c pmonitor;
00304 };
00305 
00306 
00307 #endif

Generated at Mon Jul 2 14:24:42 2001 for CAVERNsoft by doxygen1.2.8-20010617 written by Dimitri van Heesch, © 1997-2001