-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
44 lines (34 loc) · 863 Bytes
/
Main.cpp
File metadata and controls
44 lines (34 loc) · 863 Bytes
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
#include <iostream>
#include "Server.h"
#include "Client.h"
#include "Common.h"
// external libs
#pragma comment(lib, "ws2_32.lib")
#define IS_SERVER
int main(int argc, char** argv)
{
UNREFERENCED_PARAMETER(argc);
UNREFERENCED_PARAMETER(argv);
try {
#if defined(IS_SERVER)
Server server(DefaultPort);
server.listen();
server.shutdown();
#else
Client client(DefaultPort);
while (!client.connect(LocalServer)) {
std::cout << "Try to reconnect...\n";
Sleep(2000);
}
client.listen();
client.send(std::cin);
#endif
}
catch (const std::exception& ex) {
std::cout << ex.what() << '\n';
}
catch (...) {
std::cout << "An unexpected exception happend!\n";
}
return EXIT_SUCCESS;
}