Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNnet_udp_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 _CAVERNNET_UDP
00018 #define _CAVERNNET_UDP
00019 
00020 #include "CAVERNnet_socketbase_c.hxx"
00021 #include "CAVERNnet_perfMonitor_c.hxx"
00022 #include "CAVERNnet_perfDaemon_c.hxx"
00023 
00024 #ifdef WIN32
00025 #include <winsock.h>
00026 #elif defined(__sgi)
00027 extern int h_errno;
00028 #endif
00029 
00045 //class CAVERNnet_perfMonitor_c;
00046 //class CAVERNnet_perfDaemon_c;
00047 
00048 class CAVERNnet_udp_c : public CAVERNnet_socketbase_c {
00049 
00050 private:
00051         // Instrumentation flag.
00052         int enableInstr;
00053 
00054     // Socket file descriptor.
00055         int sockfd;
00056 
00057     // Timing flags for blocking mode.
00058         int timeOutStatus;
00059         int timeOutPeriod;              
00060 
00061     // Socket structures.
00062         struct sockaddr_in selfAddress, sendAddress, receiveAddress;
00063 
00064    //For performance monitoring
00065     CAVERNnet_perfMonitor_c pmonitor;
00066 
00067    // Socket blocking type.
00068         int typeOfBlocking;     
00069 
00070 public:
00071 
00073 
00074 
00075         static const int OK/* = 1*/;
00076 
00078         static const int FAILED/* = 0*/;
00079 
00081 
00083 
00084 
00085         static const int BLOCKING/* = 1*/;
00086 
00088         static const int NON_BLOCKING/* = 2*/;
00089 
00091         static const int NULL_VALUE/* =3*/;
00092 
00094 
00096 
00097 
00098         static const int NO_TIME_OUT/* = -1*/;
00099 
00101         static const int DEFAULT_TIME_OUT/* = NO_TIME_OUT*/; 
00102 
00104 
00106 
00107 
00108         static const int SOCKET_NOT_OPEN/* = -1*/;
00109 
00111         static const int TIMED_OUT/* = -4*/;
00112 
00114         static const int NON_BLOCKING_NOT_READY_TO_WRITE /* =-5*/;
00115 
00117         static const int NON_BLOCKING_HAS_NO_DATA /* =-6*/;
00118 
00119 
00121 
00122         CAVERNnet_udp_c();
00123 
00132         void enableInstrumentation();
00133 
00140         void disableInstrumentation();
00141 
00145         void setTimeOut(int t) {timeOutPeriod = t;}
00146 
00148         int getTimeOut() {return timeOutPeriod;}
00149 
00159         int init(unsigned short port = 0);
00160 
00166         int setSendAddress(char *host, unsigned short port);
00167 
00171         void copyReceiveAddressToSendAddress();
00172 
00180         CAVERNnet_udp_c * clone();
00181 
00204         int send(char *message, int length, int blockingType = CAVERNnet_udp_c::NULL_VALUE);
00205 
00230         int receive(char *message, int length,  int blockingType = CAVERNnet_udp_c::NULL_VALUE);
00231 
00232 
00236         int peek(char *message, int length);
00237 
00239         void makeNonBlocking();
00240 
00242 
00243 
00244         unsigned long getReceiveIP();
00246         void getReceiveIP(char *ip);
00248         unsigned short getReceivePort();
00249 
00251         unsigned long getSendIP();
00253         void getSendIP(char *ip);
00255         unsigned short getSendPort();
00256 
00258         unsigned long getSelfIP();
00260         void getSelfIP(char *ip);
00262         unsigned short  getSelfPort();
00264 
00265 
00267         void printInfo();
00268 
00274 #ifdef WIN32
00275         void close() {::closesocket(sockfd);}
00276 #else
00277         void close() {::close(sockfd);}
00278 #endif
00279 
00280     //Functions added for performance monitoring interface
00281     
00293     void showStats(char* streamInfo, char* comment);
00294     
00311     int logStats(char* streamInfo, char* comment, FILE* filePtr);
00312 
00327     int sendStats(char* streamInfo, char* comment);
00328 
00342     int initSendStats(char* monitorClientIP, int port = PERF_DAEMON_DEFAULT_PORT);
00343     
00348     void exitSendStats();
00349 
00350 
00351 };
00352 
00353 
00354 #endif

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