transm/server/main.cpp

41 lines
973 B
C++
Raw Normal View History

#include "server.h"
2024-12-16 14:21:39 +08:00
#include "version.h"
2024-12-14 19:49:44 +08:00
#include <iostream>
2025-01-22 09:35:38 +08:00
#ifdef _WIN32
#include <fcntl.h>
#include <io.h>
#include <windows.h>
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif
#endif
int main(int argc, char* argv[])
2024-12-11 08:44:14 +08:00
{
2025-01-22 09:35:38 +08:00
#ifdef _WIN32
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD mode;
GetConsoleMode(hConsole, &mode);
mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
SetConsoleMode(hConsole, mode);
#endif
mpinfo("Build At {} {} under {} on {}", __DATE__, __TIME__, VERSION_GIT_COMMIT, VERSION_GIT_BRANCH);
int port = 9898;
if (argc < 2) {
mpinfo("Use Default Port:{}", port);
2024-12-16 14:21:39 +08:00
} else {
std::string str_port(argv[1]);
port = std::stoi(str_port);
mpinfo("Use Port:{}", port);
}
2024-12-12 23:11:55 +08:00
asio::io_context io_context;
CTcpServer server(io_context);
if (!server.start(port)) {
2024-12-12 23:11:55 +08:00
return -1;
}
io_context.run();
2024-12-11 08:44:14 +08:00
return 0;
}