Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNnet_perfDaemon_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 #ifndef _CAVERNPLUS_PERF_DAEMON_C
00017 #define _CAVERNPLUS_PERF_DAEMON_C
00018 
00019 #include <stdio.h>
00020 
00021 #include "CAVERNnet_perfClient_c.hxx"
00022 
00023 class CAVERNnet_tcpServer_c;
00024 
00025 struct PerfDaemonClient
00026 {
00027     CAVERNnet_perfDaemonClient_c *Client;
00028     int IsPerfClient;
00029     int Started;
00030 };
00031 
00051 class CAVERNnet_perfDaemon_c
00052 {
00053 public:
00061         CAVERNnet_perfDaemon_c(FILE* File = NULL);
00062         ~CAVERNnet_perfDaemon_c();
00063 
00065 
00066         static const int OK/* = 0*/;
00067 
00069         static const int FAILED/* = 1*/;
00070 
00072         static const int MEM_ALLOC_ERR/* = 2*/;
00073 
00075         static const int NEW_CONNECTION_ESTABLISHED/* = 4*/;
00076 
00078         static const int TOO_MANY_CLIENTS/* = 5*/;
00079 
00081         static const int NO_NEW_CONNECTION/* = 6*/;
00082 
00084         static const int NON_BLOCKING_HAS_NO_DATA/* = 7*/;
00085 
00087         static const int SKIP_DISTRIBUTION/* = 8*/;
00088 
00089         static const int DEFAULT_PORT/* = 9500*/;
00091 
00097         int init(int incomingPort=PERF_DAEMON_DEFAULT_PORT, int maxClients = 64);
00098 
00103         int process();
00104 
00112         int checkForNewClients();
00113 
00130         void intercept(int (*callback) (CAVERNnet_perfDaemonClient_c *client, char** buffer, 
00131                                             int *bufferSize,  void *userData), void* userData);
00132 
00139         void interceptNewConnection(void (*callback) (CAVERNnet_perfDaemonClient_c *newClient, void* userData), void *userData);
00140 
00141         int sendToAll(char* buf, int incomingSize);
00142 
00143 private:
00144         PerfDaemonClient **clients;
00145         CAVERNnet_tcpServer_c *server;
00146         unsigned short incomingPort;
00147         FILE* LogFile;
00148 
00149         int (*interceptCallback) (CAVERNnet_perfDaemonClient_c *newClient, char** buffer, 
00150                                       int* bufsize, void *userData);
00151         void *interceptUserData;
00152 
00153         void (*interceptNewConnectionCallback) (CAVERNnet_perfDaemonClient_c *newClient, void *userData);
00154         void *interceptNewConnectionUserData;
00155 
00156         // Distribute the data to all connected performance monitoring clients.
00157         // Specify -1 if want to send to all.
00158         int distributeDataToPerfClients(char* buf, int incomingSize);
00159 
00160         // Remove a client from the client array.
00161         void removeClient(int clientNum);
00162 
00163         // Close all client sockets and remove them. Used by destructor.
00164         // Also closes down and deallocates the server.
00165         void closeDownSockets();
00166         int maxNumClients;
00167 };
00168 
00169 #endif

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