/////////////////////////////////////////////////////// Entry point of application \return Application exit code ///////////////////////////////////////////////////////
| 14 | /// |
| 15 | //////////////////////////////////////////////////////////// |
| 16 | int main() |
| 17 | { |
| 18 | // Choose a random port for opening sockets (ports < 1024 are reserved) |
| 19 | const unsigned short port = 2435; |
| 20 | |
| 21 | // Client or server ? |
| 22 | char who = 0; |
| 23 | std::cout << "Do you want to be a server ('s') or a client ('c')? "; |
| 24 | std::cin >> who; |
| 25 | |
| 26 | if (who == 's') |
| 27 | { |
| 28 | // Run as a server |
| 29 | doServer(port); |
| 30 | } |
| 31 | else |
| 32 | { |
| 33 | // Run as a client |
| 34 | doClient(port); |
| 35 | } |
| 36 | |
| 37 | // Wait until the user presses 'enter' key |
| 38 | std::cout << "Press enter to exit..." << std::endl; |
| 39 | std::cin.ignore(10'000, '\n'); |
| 40 | } |