diff --git a/Common/GmshDaemon.cpp b/Common/GmshDaemon.cpp index 253fc4022d963acf9021993ca056a2942df2891a..08d640eae95a150015b8fde905123d4d4765da18 100644 --- a/Common/GmshDaemon.cpp +++ b/Common/GmshDaemon.cpp @@ -22,7 +22,9 @@ int GmshDaemon(std::string socket) // read large data file, // initialize mpi job, // then wait for commands to execute: + bool stop = false; while(1){ + if(stop) break; // wait at most 1 second for data if(!client.Select(1, 0)){ int type, length; @@ -33,23 +35,34 @@ int GmshDaemon(std::string socket) tmp << "Hello! I've received msg type=" << type << " len=" << length << " str=" << msg; client.Info(tmp.str().c_str()); - if(type == GmshSocket::GMSH_STOP){ - client.Info("Stopping connection!"); - delete [] msg; + switch(type){ + case GmshSocket::GMSH_STOP: + { + client.Info("Stopping connection!"); + stop = true; + } break; - } - else{ - std::ostringstream v; - v << "View \"test\" {\n"; - for(int i= 0; i < 100; i++){ - for(int j= 0; j < 100; j++){ - v << "SQ("<<i<<","<<j<<",0, "<<i+1<<","<<j<<",0, " - <<i+1<<","<<j+1<<",0, "<<i<<","<<j+1<<",0){" - <<i+j<<","<<i+j<<","<<i+j<<","<<i+j<<"};\n"; + case GmshSocket::GMSH_SPEED_TEST: + { + std::string huge(500000000, 'a'); + client.SpeedTest(huge.c_str()); + } + break; + default: + { + std::ostringstream v; + v << "View \"test\" {\n"; + for(int i = 0; i < 100; i++){ + for(int j = 0; j < 100; j++){ + v << "SQ("<<i<<","<<j<<",0, "<<i+1<<","<<j<<",0, " + <<i+1<<","<<j+1<<",0, "<<i<<","<<j+1<<",0){" + <<i+j<<","<<i+j<<","<<i+j<<","<<i+j<<"};\n"; + } } + v << "};BoundingBox;\n"; + client.ParseString(v.str().c_str()); } - v << "};BoundingBox;\n"; - client.ParseString(v.str().c_str()); + break; } } delete [] msg; diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp index 166d53dbb677bc940d4e3c6950e5c3b6c2a50365..cb67d6014942bd10556000fb3cee9340d37125f1 100644 --- a/Fltk/menuWindow.cpp +++ b/Fltk/menuWindow.cpp @@ -156,7 +156,7 @@ static void file_remote_cb(Fl_Widget *w, void *data) Msg::Error("A server is already running"); } else{ - GmshRemote::get(99)->name = "Gmsh server"; + GmshRemote::get(99)->name = "Remote"; GmshRemote::get(99)->executable = "./gmsh"; GmshRemote::get(99)->socketSwitch = "-socket %s"; GmshRemote::get(99)->run(""); @@ -166,7 +166,7 @@ static void file_remote_cb(Fl_Widget *w, void *data) if(GmshRemote::get(99)->getServer()){ Msg::Info("Stopping remote Gmsh server"); GmshRemote::get(99)->getServer()->SendString - (GmshSocket::GMSH_STOP, "DISCONNECTING!"); + (GmshSocket::GMSH_STOP, "Disconnect!"); } else{ Msg::Error("Cannot stop remote Gmsh: server not running"); @@ -175,7 +175,8 @@ static void file_remote_cb(Fl_Widget *w, void *data) else if(str == "test"){ if(GmshRemote::get(99)->getServer()){ Msg::Info("Testing remote Gmsh server"); - GmshRemote::get(99)->getServer()->SendString(9999, "GENERATE A VIEW!"); + GmshRemote::get(99)->getServer()->SendString + (GmshSocket::GMSH_SPEED_TEST, "Send me a huge amount of data!"); } else{ Msg::Error("Cannot test remote Gmsh: server not running");