Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNnet_remoteFileIO32_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_remoteFileIO32_c
00018 #define _CAVERNnet_remoteFileIO32_c
00019 
00020 #include "CAVERN.hxx"
00021 #include "CAVERNnet_extendedTcp_c.hxx"
00022 #include "CAVERNmisc_fileList_c.hxx"
00023 
00024 #ifdef WIN32
00025 #include <stdlib.h>
00026 #define MAXPATHLEN      MAX_PATH
00027 #else
00028 #include <sys/param.h>
00029 #endif
00030 
00041 class CAVERNnet_remoteFileIOServer32_c {
00042 public:
00046         static const int DEFAULT_PORT/* = 8000*/;
00047 
00049         static const int THREADED/* = 1*/;
00050 
00052         static const int NON_THREADED/* = 0*/;
00053 
00055         int init(int inPort=CAVERNnet_remoteFileIOServer32_c::DEFAULT_PORT, 
00056                      char* neighborServer = NULL, 
00057                          int neighborPort = CAVERNnet_remoteFileIOServer32_c::DEFAULT_PORT, 
00058                          int storeLocally = 1);
00059 
00069         void process(int threaded = CAVERNnet_remoteFileIOServer32_c::NON_THREADED);
00070 
00071         void setRemotePort(int port=CAVERNnet_remoteFileIOServer32_c::DEFAULT_PORT) { 
00072                 neighborPortNumber = port;
00073         }
00074         void setNeighborServer(char* ServerName) { 
00075                 if (ServerName) strcpy(neighborServerName, ServerName);
00076                 else neighborServerName[0] = '\0';
00077         }
00078         void setStore(int StoreLocally) { store = StoreLocally; }
00079 
00080         long getFileSize(FILE* readFile);
00081 
00082         static const int TRANSFERSIZE/* = 30000*/;
00083 
00084 private:
00085         CAVERNnet_extendedTcpServer_c server;
00086         char neighborServerName[MAXPATHLEN];
00087         int neighborPortNumber;
00088         int store;
00089 
00090         static int getHostIPNumber(char* hostNameOrIP);
00091         static void* threadHandler(void*);
00092 };
00093 
00096 class CAVERNnet_remoteFileIOClient32_c {
00097         public:
00098 
00100 
00101         static const int OK/* = 1*/;
00102 
00104         static const int FAILED/* = 0*/;
00105 
00107         static const int CANNOT_CONNECT/* = 2*/;
00108 
00110         static const int CANNOT_READ_LOCAL_FILE/* = 3*/;
00111 
00113         static const int CANNOT_WRITE_LOCAL_FILE/* = 3*/;
00114 
00116         static const int INVALID_COMMAND/* = 4*/;
00117 
00119         static const int MEM_ALLOC_ERR/* = 5*/;
00120 
00122         static const int FILE_ERROR/* = 6*/;
00123 
00125         static const int EARLIER/* = 7*/;
00126 
00128         static const int LATER/* = 8*/;
00129 
00131         static const int SAME/* = 9*/;
00132 
00134 
00135         CAVERNnet_remoteFileIOClient32_c();
00136 
00138         void setRemotePort(int port = CAVERNnet_remoteFileIOServer32_c::DEFAULT_PORT);
00139 
00147         int upload(char* ipAddress,char* localFileName, char* remoteFileName);
00148 
00156         int download(char* ipAddress, char* localFilename, char* remoteFileName);
00157 
00163         int getRemoteDateTime(char* ipAddress, char* remoteFileName,
00164                               int *remDay, int *remMon, int *remYear,
00165                               int* remHour, int* remMin, int* remSec);
00166 
00167 #if (defined(__sgi) || defined(linux) || defined(sun))
00168 
00177     int getRemoteFileList(char* ipAddress, char* remotePath, CAVERNmisc_fileInfo_c*& fileList, int* noObjects, int doRecursion = CAVERNmisc_fileList_c::SKIP_RECURSION, int linkTraversal = CAVERNmisc_fileList_c::DO_NOT_TRAVERSE_LINKS);
00178 #endif    
00179 
00184         static int getLocalDateTime(char* filename,
00185                  int *day,
00186                  int *month,
00187                  int *year,
00188                  int *hour,
00189                  int *minute,
00190                  int *second);
00191 
00198         int compareDateTime(int day1, int month1, int year1,
00199                 int hour1, int minute1, int second1,
00200                 int day2, int month2, int year2,
00201                 int hour2, int minute2, int second2);
00202 
00203     //Functions added for performance monitoring interface
00204     
00217     void showStats(char* streamInfo, char* comment);
00218     
00235     int logStats(char* streamInfo, char* comment, FILE* filePtr);
00236 
00251     int sendStats(char* streamInfo, char* comment);
00252 
00266     int initSendStats(char* monitorClientIP, int port = PERF_DAEMON_DEFAULT_PORT);
00267     
00272     void exitSendStats();
00273 
00274 private:
00275         int remotePort;
00276         CAVERNnet_extendedTcpClient_c client;
00277     CAVERNnet_perfMonitor_c pmonitor;   //for performance monitoring
00278 };
00279 
00280 /*
00281 
00282 FORMAT:There are no spaces between fields
00283 
00284 UPLOAD
00285 ------
00286 CLIENT -> SERVER
00287 u fileNameLen fileName dataSize data
00288 
00289 DOWNLOAD
00290 --------
00291 CLIENT -> SERVER
00292 d fileNameLen  fileName
00293 SERVER->CLIENT
00294 d (dataSize, timeStamp) data
00295 
00296 CHECK REMOTE TIMESTAMP ON FILE
00297 -----------------------------
00298 CLIENT->SERVER
00299 c fileNameLen fileName
00300 SERVER->CLIENT
00301 c (time, timestamp)
00302 
00303 GET REMOTE FILE LIST
00304 -------------------
00305 CLIENT->SERVER
00306 f pathname_size pathname recursion_flag
00307 SERVER->CLIENT
00308 f no_objects (dataSize+timestamp) packed_file_list
00309 (if no_objects = -1, it means a file error)
00310 
00311 REPLY:SERVER->CLIENT (For all commands)
00312 
00313 File Not found:  'n'
00314 Invalid command: 't' 
00315 
00316 */
00317 
00318 #endif
00319 
00320 
00321 

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