/////////////////////////////////////////////////////// Entry point of application \return Application exit code ///////////////////////////////////////////////////////
| 14 | /// |
| 15 | //////////////////////////////////////////////////////////// |
| 16 | int main() |
| 17 | { |
| 18 | // Choose an arbitrary port for opening sockets |
| 19 | const unsigned short port = 50001; |
| 20 | |
| 21 | // TCP, UDP or connected UDP ? |
| 22 | char protocol = 0; |
| 23 | std::cout << "Do you want to use TCP (t) or UDP (u)? "; |
| 24 | std::cin >> protocol; |
| 25 | |
| 26 | // Client or server ? |
| 27 | char who = 0; |
| 28 | std::cout << "Do you want to be a server (s) or a client (c)? "; |
| 29 | std::cin >> who; |
| 30 | |
| 31 | if (protocol == 't') |
| 32 | { |
| 33 | // Enable TLS ? |
| 34 | char tls = 0; |
| 35 | std::cout << "Do you want to enable TLS (y) or not (n)? "; |
| 36 | std::cin >> tls; |
| 37 | |
| 38 | // Test the TCP protocol |
| 39 | if (who == 's') |
| 40 | runTcpServer(port, tls == 'y'); |
| 41 | else |
| 42 | runTcpClient(port, tls == 'y'); |
| 43 | } |
| 44 | else |
| 45 | { |
| 46 | // Test the unconnected UDP protocol |
| 47 | if (who == 's') |
| 48 | runUdpServer(port); |
| 49 | else |
| 50 | runUdpClient(port); |
| 51 | } |
| 52 | |
| 53 | // Wait until the user presses 'enter' key |
| 54 | std::cout << "Press enter to exit..." << std::endl; |
| 55 | std::cin.ignore(10'000, '\n'); |
| 56 | std::cin.ignore(10'000, '\n'); |
| 57 | } |
nothing calls this directly
no test coverage detected