Add host name

This commit is contained in:
Nikola Petrov 2025-03-27 14:32:56 +01:00
parent 2cd8ef5558
commit 64364bfefd

View File

@ -16,6 +16,7 @@
#define DATA_FILE_NAME "DATA.bin" #define DATA_FILE_NAME "DATA.bin"
#define VECTOR_FILE_NAME "VECTOR.bin" #define VECTOR_FILE_NAME "VECTOR.bin"
#define GEN_FILE_PATTRN "gen/%04d.bin" #define GEN_FILE_PATTRN "gen/%04d.bin"
#define HOST_NAME "petrovv.com"
void DnaStore::load(DnaManagerData *data) void DnaStore::load(DnaManagerData *data)
{ {
@ -149,24 +150,24 @@ void DnaStore::saveGen(DnaManagerData *data)
sync(); sync();
} }
void client(std::string prefix); void client(std::string_view prefix);
void DnaStore::sync() void DnaStore::sync()
{ {
const char *prefix = sys::transformFilePath(""); const char *prefix = sys::transformFilePath("");
std::string prefixs = prefix; std::string_view prefixs = prefix;
std::thread t(client, prefixs); std::thread t(client, prefixs);
t.detach(); t.detach();
} }
void client(std::string prefix) void client(std::string_view prefix)
{ {
constexpr int extra_buff = 22; // len of 2**31 -> 2147483648 plus the pattern size constexpr int extra_buff = 22; // len of 2**31 -> 2147483648 plus the pattern size
std::string buffer; std::string buffer;
buffer.resize(prefix.size() + extra_buff); buffer.resize(prefix.size() + extra_buff);
int sock = TcpSocket::connectt("petrovv.com", keyPort); int sock = TcpSocket::connectt(HOST_NAME, keyPort);
if (sock < 0) if (sock < 0)
{ {
return; return;
@ -177,7 +178,7 @@ void client(std::string prefix)
TcpSocket::closet(sock); TcpSocket::closet(sock);
sock = TcpSocket::connectt("petrovv.com", serverPort); sock = TcpSocket::connectt(HOST_NAME, serverPort);
if (sock < 0) if (sock < 0)
{ {