X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/7e74b790d290cd7d776349503bb361c47933c01f..20fc4099b4db2caf4130d3b5d3bb61182167c75b:/Server/tests/server_test.cpp?ds=sidebyside diff --git a/Server/tests/server_test.cpp b/Server/tests/server_test.cpp index 25d01a6..1f505ee 100644 --- a/Server/tests/server_test.cpp +++ b/Server/tests/server_test.cpp @@ -29,12 +29,15 @@ #include "plaqui/server/server.h" #include "plaqui/server/string.h" #include +#include #include #include using namespace std; using namespace PlaQui::Server; +Server* server = NULL; + void on_error(const Runnable::Error& code, const string& desc) { cerr << "--------------------------------------------------------" << endl; cerr << "Error en el servidor:" << endl; @@ -43,6 +46,11 @@ void on_error(const Runnable::Error& code, const string& desc) { cerr << "--------------------------------------------------------" << endl; } +void on_finished(void) { + cerr << "MuriĆ³ el servidor!" << endl; + server = NULL; +} + int main(int argc, char* argv[]) { // Termina con mas informacion si hay una excepcion no manejada. @@ -68,7 +76,6 @@ int main(int argc, char* argv[]) { // Inicializa threads. Glib::thread_init(); - Server* server = NULL; try { // Crea el server (empieza a escuchar). server = new Server(filename, port); @@ -108,8 +115,13 @@ int main(int argc, char* argv[]) { // Corre el server. server->run(false); + // Espera a que el server se muera. + while (server) { + Glib::usleep(1000000); + } + // Como no detachee el server, lo tengo que eliminar a mano. - delete server; + //delete server; return 0; }