| 96 | // ---------------------------------------------------------------------------------------- |
| 97 | |
| 98 | void test1() |
| 99 | { |
| 100 | dlog << LINFO << "in test1()"; |
| 101 | serv theserv; |
| 102 | theserv.set_listening_port(12345); |
| 103 | theserv.start_async(); |
| 104 | |
| 105 | // wait a little bit to make sure the server has started listening before we try |
| 106 | // to connect to it. |
| 107 | dlib::sleep(500); |
| 108 | |
| 109 | for (int i = 0; i < 200; ++i) |
| 110 | { |
| 111 | dlog << LINFO << "i: " << i; |
| 112 | print_spinner(); |
| 113 | iosockstream stream("localhost:12345"); |
| 114 | |
| 115 | stream << "word another "; |
| 116 | std::string temp; |
| 117 | stream >> temp; |
| 118 | DLIB_TEST(temp == "yay"); |
| 119 | stream >> temp; |
| 120 | DLIB_TEST(temp == "words"); |
| 121 | stream << "yep "; |
| 122 | } |
| 123 | |
| 124 | // Just to make sure the server finishes processing the last connection before |
| 125 | // we kill it and accidentally trigger a DLIB_TEST(). |
| 126 | dlib::sleep(500); |
| 127 | |
| 128 | if (theserv.error_string.size() != 0) |
| 129 | throw error(theserv.error_string); |
| 130 | } |
| 131 | |
| 132 | // ---------------------------------------------------------------------------------------- |
| 133 |
no test coverage detected