| 150 | //---------------------------------------------------------------------- |
| 151 | |
| 152 | int main(int argc, char* argv[]) |
| 153 | { |
| 154 | try |
| 155 | { |
| 156 | if (argc != 4) |
| 157 | { |
| 158 | std::cerr << "Usage: blocking_tcp_client <host> <port> <message>\n"; |
| 159 | return 1; |
| 160 | } |
| 161 | |
| 162 | client c; |
| 163 | c.connect(argv[1], argv[2], std::chrono::seconds(10)); |
| 164 | |
| 165 | auto time_sent = std::chrono::steady_clock::now(); |
| 166 | |
| 167 | c.write_line(argv[3], std::chrono::seconds(10)); |
| 168 | |
| 169 | for (;;) |
| 170 | { |
| 171 | std::string line = c.read_line(std::chrono::seconds(10)); |
| 172 | |
| 173 | // Keep going until we get back the line that was sent. |
| 174 | if (line == argv[3]) |
| 175 | break; |
| 176 | } |
| 177 | |
| 178 | auto time_received = std::chrono::steady_clock::now(); |
| 179 | |
| 180 | std::cout << "Round trip time: "; |
| 181 | std::cout << std::chrono::duration_cast< |
| 182 | std::chrono::microseconds>( |
| 183 | time_received - time_sent).count(); |
| 184 | std::cout << " microseconds\n"; |
| 185 | } |
| 186 | catch (std::exception& e) |
| 187 | { |
| 188 | std::cerr << "Exception: " << e.what() << "\n"; |
| 189 | } |
| 190 | |
| 191 | return 0; |
| 192 | } |
nothing calls this directly
no test coverage detected