blob: c4755420877726ed9d27cf5821c3d96950edf842 (
plain)
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
|
#include <Server.hpp>
void ConnectionHandler(Networking::TCPConnection &Connection)
{
ByteArray Bytes = Connection.ReceiveBytes();
for(auto &It : Bytes)
printf("%02x ", It);
printf("\n");
Connection.SendBytes(Bytes);
}
int __stdcall WinMain(HINSTANCE, HINSTANCE, char*, int)
{
// Open a debugging console.
Utils::OpenConsole();
// Create an instance of the TCP server.
Networking::TCPServer Server;
// Attach our connection handler.
Server += ConnectionHandler;
bool Result = Server.Start(SERVER_PORT);
if(Result)
{
// Accept any incoming connections.
for(;;)
Server.AcceptConnection();
}
if(!Result)
printf("[FAIL] Failed to initialise server. (%08lx)\n", WSAGetLastError());
system("pause");
}
|