2014-09-30 22:07:25 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Headers
|
|
|
|
////////////////////////////////////////////////////////////
|
2024-09-24 03:55:33 +08:00
|
|
|
#include "Client.hpp"
|
|
|
|
#include "Server.hpp"
|
2014-09-30 22:07:25 +08:00
|
|
|
|
2024-09-24 03:55:33 +08:00
|
|
|
#include <iostream>
|
2014-09-30 22:07:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// 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 ?
|
2024-04-27 14:44:27 +08:00
|
|
|
char who = 0;
|
2014-11-17 16:44:46 +08:00
|
|
|
std::cout << "Do you want to be a server ('s') or a client ('c')? ";
|
2022-07-05 00:20:58 +08:00
|
|
|
std::cin >> who;
|
2014-09-30 22:07:25 +08:00
|
|
|
|
|
|
|
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');
|
|
|
|
}
|