X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=test%2Fhello.cpp;h=302fb482bbb90cced6518852efd44da36c3f8c98;hp=1036e30908748276b947c5b0edbc83289090e652;hb=441d41fe583765902aa2f9641c0977e295e62be3;hpb=696c95c2808d6f88df2b348f9e77fc66c9068976 diff --git a/test/hello.cpp b/test/hello.cpp index 1036e30..302fb48 100644 --- a/test/hello.cpp +++ b/test/hello.cpp @@ -97,19 +97,26 @@ class test_hello : public TestFixture case 0: // child { - socket_server ss("./socket"); + try + { + socket_server ss("./socket"); + + ostringstream hello; + hello << "T2Nv" << PROTOCOL_VERSION << ';'; + int byteordercheck=1; + hello.write((char*)&byteordercheck,sizeof(byteordercheck)); + hello << ';'; + + ss.add_callback(new_connection,bind(&test_hello::send_hello, boost::ref(*this), hello.str(),&ss, _1)); + + // max 10 sec + for (int i=0; i < 10; i++) + ss.fill_buffer(1000000); + } catch(...) + { + std::cerr << "exception in child. ignoring\n"; + } - ostringstream hello; - hello << "T2Nv" << PROTOCOL_VERSION << ';'; - int byteordercheck=1; - hello.write((char*)&byteordercheck,sizeof(byteordercheck)); - hello << ';'; - - ss.add_callback(new_connection,bind(&test_hello::send_hello, boost::ref(*this), hello.str(),&ss, _1)); - - // max 10 sec - for (int i=0; i < 10; i++) - ss.fill_buffer(1000000); // don't call atexit and stuff _exit(0); } @@ -139,16 +146,23 @@ class test_hello : public TestFixture case 0: // child { - socket_server ss("./socket"); + try + { + socket_server ss("./socket"); - ostringstream hello; - hello << "XYZ 123"; + ostringstream hello; + hello << "XYZ 123"; - ss.add_callback(new_connection,bind(&test_hello::send_hello, boost::ref(*this), hello.str(),&ss, _1)); + ss.add_callback(new_connection,bind(&test_hello::send_hello, boost::ref(*this), hello.str(),&ss, _1)); + + // max 10 sec + for (int i=0; i < 10; i++) + ss.fill_buffer(1000000); + } catch(...) + { + std::cerr << "exception in child. ignoring\n"; + } - // max 10 sec - for (int i=0; i < 10; i++) - ss.fill_buffer(1000000); // don't call atexit and stuff _exit(0); } @@ -187,20 +201,27 @@ class test_hello : public TestFixture case 0: // child { - socket_server ss("./socket"); - - ostringstream hello; - // lets hope we don't ever get near such a version number... - hello << "T2Nv" << 4982271 << ';'; - int byteordercheck=1; - hello.write((char*)&byteordercheck,sizeof(byteordercheck)); - hello << ';'; + try + { + socket_server ss("./socket"); + + ostringstream hello; + // lets hope we don't ever get near such a version number... + hello << "T2Nv" << 4982271 << ';'; + int byteordercheck=1; + hello.write((char*)&byteordercheck,sizeof(byteordercheck)); + hello << ';'; + + ss.add_callback(new_connection,bind(&test_hello::send_hello, boost::ref(*this), hello.str(),&ss, _1)); + + // max 10 sec + for (int i=0; i < 10; i++) + ss.fill_buffer(1000000); + } catch(...) + { + std::cerr << "exception in child. ignoring\n"; + } - ss.add_callback(new_connection,bind(&test_hello::send_hello, boost::ref(*this), hello.str(),&ss, _1)); - - // max 10 sec - for (int i=0; i < 10; i++) - ss.fill_buffer(1000000); // don't call atexit and stuff _exit(0); } @@ -239,19 +260,26 @@ class test_hello : public TestFixture case 0: // child { - socket_server ss("./socket"); - - ostringstream hello; - hello << "T2Nv" << PROTOCOL_VERSION; - int byteordercheck=1; - hello.write((char*)&byteordercheck,sizeof(byteordercheck)); - hello << ';'; - - ss.add_callback(new_connection,bind(&test_hello::send_hello, boost::ref(*this), hello.str(),&ss, _1)); + try + { + socket_server ss("./socket"); + + ostringstream hello; + hello << "T2Nv" << PROTOCOL_VERSION; + int byteordercheck=1; + hello.write((char*)&byteordercheck,sizeof(byteordercheck)); + hello << ';'; + + ss.add_callback(new_connection,bind(&test_hello::send_hello, boost::ref(*this), hello.str(),&ss, _1)); + + // max 10 sec + for (int i=0; i < 10; i++) + ss.fill_buffer(1000000); + } catch(...) + { + std::cerr << "exception in child. ignoring\n"; + } - // max 10 sec - for (int i=0; i < 10; i++) - ss.fill_buffer(1000000); // don't call atexit and stuff _exit(0); } @@ -290,28 +318,35 @@ class test_hello : public TestFixture case 0: // child { - socket_server ss("./socket"); + try + { + socket_server ss("./socket"); + + ostringstream hello; + hello << "T2Nv" << PROTOCOL_VERSION << ';'; + int byteordercheck=1; + int dst; + char* si=(char*)&byteordercheck; + char* di=(char*)&dst; + + di[0]=si[3]; + di[1]=si[2]; + di[2]=si[1]; + di[3]=si[0]; + + hello.write((char*)&dst,sizeof(dst)); + hello << ';'; + + ss.add_callback(new_connection,bind(&test_hello::send_hello, boost::ref(*this), hello.str(),&ss, _1)); + + // max 10 sec + for (int i=0; i < 10; i++) + ss.fill_buffer(1000000); + } catch(...) + { + std::cerr << "exception in child. ignoring\n"; + } - ostringstream hello; - hello << "T2Nv" << PROTOCOL_VERSION << ';'; - int byteordercheck=1; - int dst; - char* si=(char*)&byteordercheck; - char* di=(char*)&dst; - - di[0]=si[3]; - di[1]=si[2]; - di[2]=si[1]; - di[3]=si[0]; - - hello.write((char*)&dst,sizeof(dst)); - hello << ';'; - - ss.add_callback(new_connection,bind(&test_hello::send_hello, boost::ref(*this), hello.str(),&ss, _1)); - - // max 10 sec - for (int i=0; i < 10; i++) - ss.fill_buffer(1000000); // don't call atexit and stuff _exit(0); } @@ -350,17 +385,24 @@ class test_hello : public TestFixture case 0: // child { - socket_server ss("./socket"); + try + { + socket_server ss("./socket"); + + ostringstream hello; + // hmm, we got the wrong socket + hello << "* OK intradev.net.lan Cyrus IMAP4 v2.2.13 server ready"; - ostringstream hello; - // hmm, we got the wrong socket - hello << "* OK intradev.net.lan Cyrus IMAP4 v2.2.13 server ready"; + ss.add_callback(new_connection,bind(&test_hello::send_raw_socket, boost::ref(*this), hello.str(),&ss, _1)); - ss.add_callback(new_connection,bind(&test_hello::send_raw_socket, boost::ref(*this), hello.str(),&ss, _1)); + // max 3 sec + for (int i=0; i < 3; i++) + ss.fill_buffer(1000000); + } catch(...) + { + std::cerr << "exception in child. ignoring\n"; + } - // max 3 sec - for (int i=0; i < 3; i++) - ss.fill_buffer(1000000); // don't call atexit and stuff _exit(0); } @@ -399,17 +441,24 @@ class test_hello : public TestFixture case 0: // child { - socket_server ss("./socket"); + try + { + socket_server ss("./socket"); + + ostringstream hello; + // hmm, we got the wrong socket + hello << "READY"; - ostringstream hello; - // hmm, we got the wrong socket - hello << "READY"; + ss.add_callback(new_connection,bind(&test_hello::send_raw_socket, boost::ref(*this), hello.str(),&ss, _1)); - ss.add_callback(new_connection,bind(&test_hello::send_raw_socket, boost::ref(*this), hello.str(),&ss, _1)); + // max 3 sec + for (int i=0; i < 3; i++) + ss.fill_buffer(1000000); + } catch(...) + { + std::cerr << "exception in child. ignoring\n"; + } - // max 3 sec - for (int i=0; i < 3; i++) - ss.fill_buffer(1000000); // don't call atexit and stuff _exit(0); }