#include #include #include #include "templ.h" #include "Server.h" #include // To wait until killed by the client extern HPCxx_Sync *mywait; // Ignore the command line arguments that are being passed on by Globus, // just print the host on which this server is running. ( Globus sends a // set of arguments when the new context is created ). void parseArguments(int argc, char **argv) { const int maxLengthOfName = 100; char localHostName [maxLengthOfName]; int error = gethostname(localHostName, maxLengthOfName); if (error){ cout << "Error ... gethostname() failed ... exiting \n"; exit(EXIT_FAILURE); } cout << "Gramtest-Server is running on: " << localHostName << endl; } // Start running the server void runServer(int argc, char **argv) { // Register all the functions that the server context exports. Server::registerAll(); // Wait until killed by the client. mywait = new HPCxx_Sync; int killMe = *mywait; cout << "Component has been killed! \n "; cout << "Server exiting ... \n"; cout.flush(); // Wait for a few seconds for the killMe request from the client to // return back. sleep(5); } // The main function. int main(int argc, char **argv) { // Required for any context created using hpcxx_createContext. The newly // created context is essentially an "agent" for the "creator" context. hpcxx_initAgent(argc, argv); cout << "Server: in main(): hpcxx_initAgent done \n"; cout.flush(); parseArguments(argc, argv); runServer(argc, argv); // Call this before exiting. Used for cleanup. hpcxx_exit(); }