00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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;
00042
00045 static const int DEFAULT_PORT;
00046
00048 static const int OK;
00049
00051 static const int CANNOT_MANAGE_ANY_MORE;
00052
00054 static const int RPC_NOT_FOUND;
00055
00057 static const int MEM_ALLOC_ERR;
00058
00060 static const int FAILED;
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
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
00168 int replyRPC(CAVERNnet_tcpClient_c *client, char* returnValue, int returnSize);
00169
00170
00171 CAVERNnet_rpcHandle_c *findRPC(char*);
00172
00173
00174 int handleRPC(CAVERNnet_tcpClient_c *client);
00175
00176
00177 CAVERNnet_perfMonitor_c pmonitor;
00178 };
00179
00182 class CAVERNnet_rpcCaller_c
00183 {
00184 public:
00186
00187 static const int NEVER_TIME_OUT;
00189 static const int FAILED;
00190
00192 static const int OK;
00193
00195 static const int MEM_ALLOC_ERR;
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
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
00303 CAVERNnet_perfMonitor_c pmonitor;
00304 };
00305
00306
00307 #endif