X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=test%2Fcomm.cpp;h=47ca385f13027f9d41cbe1dc689b942aaf9a93d5;hp=7bd8b242a2ea86d79ffc19ca3ea73765f32d16cc;hb=441d41fe583765902aa2f9641c0977e295e62be3;hpb=696c95c2808d6f88df2b348f9e77fc66c9068976 diff --git a/test/comm.cpp b/test/comm.cpp index 7bd8b24..47ca385 100644 --- a/test/comm.cpp +++ b/test/comm.cpp @@ -69,10 +69,17 @@ class test_comm : public TestFixture case 0: // child { - // wait till server is up - sleep(1); - socket_client_connection sc("./socket"); - sc.write("hello"); + try + { + // wait till server is up + sleep(1); + socket_client_connection sc("./socket"); + sc.write("hello"); + } catch(...) + { + std::cerr << "exception in child. ignoring\n"; + } + // don't call atexit and stuff _exit(0); } @@ -109,32 +116,39 @@ class test_comm : public TestFixture case 0: // child { - socket_server ss("./socket"); - ss.set_logging(&cerr,debug); - - time_t t0 = time(NULL); - - // max 10 sec - while (time(NULL) < t0 + 10 ) + try { - ss.fill_buffer(1000000); + socket_server ss("./socket"); + ss.set_logging(&cerr,debug); - string data; - unsigned int cid; + time_t t0 = time(NULL); - if(ss.get_packet(data,cid)) + // max 10 sec + while (time(NULL) < t0 + 10 ) { - server_connection* con=ss.get_connection(cid); + ss.fill_buffer(1000000); - if (data=="QUIT") - break; + string data; + unsigned int cid; - if (data=="ABC") - con->write("DEF"); - else - con->write("xyz"); + if(ss.get_packet(data,cid)) + { + server_connection* con=ss.get_connection(cid); + + if (data=="QUIT") + break; + + if (data=="ABC") + con->write("DEF"); + else + con->write("xyz"); + } } + } catch(...) + { + std::cerr << "exception in child. ignoring\n"; } + // don't call atexit and stuff _exit(0); } @@ -179,30 +193,37 @@ class test_comm : public TestFixture case 0: // child { - socket_server ss("./socket"); - ss.set_logging(&cerr,debug); - - time_t t0 = time(NULL); - - // max 10 sec - while (time(NULL) < t0 + 10 ) + try { - ss.fill_buffer(1000000); + socket_server ss("./socket"); + ss.set_logging(&cerr,debug); - string data; - unsigned int cid; + time_t t0 = time(NULL); - if(ss.get_packet(data,cid)) + // max 10 sec + while (time(NULL) < t0 + 10 ) { - server_connection* con=ss.get_connection(cid); + ss.fill_buffer(1000000); - if (data=="QUIT") - break; + string data; + unsigned int cid; - con->write(string().insert(0,100*1024,'y')); + if(ss.get_packet(data,cid)) + { + server_connection* con=ss.get_connection(cid); + + if (data=="QUIT") + break; + + con->write(string().insert(0,100*1024,'y')); + } } + std::cerr << "child: OVER" << std::endl; + } catch(...) + { + std::cerr << "exception in child. ignoring\n"; } - std::cerr << "child: OVER" << std::endl; + // don't call atexit and stuff _exit(0); } @@ -242,10 +263,17 @@ class test_comm : public TestFixture case 0: // child { - // wait till server is up - sleep(1); - socket_client_connection sc(6666); - sc.write("hello"); + try + { + // wait till server is up + sleep(1); + socket_client_connection sc(6666); + sc.write("hello"); + } catch(...) + { + std::cerr << "exception in child. ignoring\n"; + } + // don't call atexit and stuff _exit(0); } @@ -282,31 +310,37 @@ class test_comm : public TestFixture case 0: // child { - socket_server ss(6666); - ss.set_logging(&cerr,debug); - - time_t t0 = time(NULL); - - // max 10 sec - while (time(NULL) < t0 + 10 ) + try { - ss.fill_buffer(1000000); + socket_server ss(6666); + ss.set_logging(&cerr,debug); - string data; - unsigned int cid; + time_t t0 = time(NULL); - if(ss.get_packet(data,cid)) + // max 10 sec + while (time(NULL) < t0 + 10 ) { - server_connection* con=ss.get_connection(cid); + ss.fill_buffer(1000000); + + string data; + unsigned int cid; - if (data=="QUIT") - break; + if(ss.get_packet(data,cid)) + { + server_connection* con=ss.get_connection(cid); - if (data=="ABC") - con->write("DEF"); - else - con->write("xyz"); + if (data=="QUIT") + break; + + if (data=="ABC") + con->write("DEF"); + else + con->write("xyz"); + } } + } catch(...) + { + std::cerr << "exception in child. ignoring\n"; } // don't call atexit and stuff _exit(0); @@ -352,31 +386,37 @@ class test_comm : public TestFixture case 0: // child { - socket_server ss(6666); - ss.set_logging(&cerr,debug); - - time_t t0 = time(NULL); - - // max 10 sec - while (time(NULL) < t0 + 10 ) + try { - ss.fill_buffer(1000000); + socket_server ss(6666); + ss.set_logging(&cerr,debug); - string data; - unsigned int cid; + time_t t0 = time(NULL); - if(ss.get_packet(data,cid)) + // max 10 sec + while (time(NULL) < t0 + 10 ) { - server_connection* con=ss.get_connection(cid); + ss.fill_buffer(1000000); - socket_handler* alias= dynamic_cast< socket_handler* >(con); + string data; + unsigned int cid; - if (data=="QUIT") - break; + if(ss.get_packet(data,cid)) + { + server_connection* con=ss.get_connection(cid); - alias->set_write_block_size( 4093 ); - con->write(string().insert(0,2048*1024,'y')); + socket_handler* alias= dynamic_cast< socket_handler* >(con); + + if (data=="QUIT") + break; + + alias->set_write_block_size( 4093 ); + con->write(string().insert(0,2048*1024,'y')); + } } + } catch(...) + { + std::cerr << "exception in child. ignoring\n"; } // don't call atexit and stuff _exit(0);