Root/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include <iomanip> #include <iostream> #include <cstdlib> //////////////////////////////////////////////////////////// // Function prototypes // (I'm too lazy to put them into separate headers...) //////////////////////////////////////////////////////////// void doClient(unsigned short port); void doServer(unsigned short port); //////////////////////////////////////////////////////////// /// Entry point of application /// /// \return Application exit code /// //////////////////////////////////////////////////////////// int main() { // Choose a random port for opening sockets (ports < 1024 are reserved) const unsigned short port = 2435; // Client or server ? char who; std::cout << "Do you want to be a server ('s') or a client ('c') ? " ; std::cin >> who; if (who == 's' ) { // Run as a server doServer(port); } else { // Run as a client doClient(port); } // Wait until the user presses 'enter' key std::cout << "Press enter to exit..." << std::endl; std::cin.ignore(10000, '\n' ); return EXIT_SUCCESS; } |
Source at commit tip created 11 years 11 months ago. By Nathan Adams, Initial commit |
---|