Update libraries and replace zlib with zstd #42

This commit is contained in:
yuanyuanxiang
2025-01-15 18:49:15 +08:00
parent 8ec3e83d31
commit 914eefbb23
29 changed files with 4790 additions and 2057 deletions

View File

@@ -92,9 +92,9 @@ inline string GetIPAddress(const char *hostName)
{
struct hostent *host = gethostbyname(hostName);
#ifdef _DEBUG
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ: %s.\n", host->h_addrtype == AF_INET ? "IPV4" : "IPV6");
Mprintf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ: %s.\n", host->h_addrtype == AF_INET ? "IPV4" : "IPV6");
for (int i = 0; host->h_addr_list[i]; ++i)
printf("<EFBFBD><EFBFBD>ȡ<EFBFBD>ĵ<EFBFBD>%d<><64>IP: %s\n", i+1, inet_ntoa(*(struct in_addr*)host->h_addr_list[i]));
Mprintf("<EFBFBD><EFBFBD>ȡ<EFBFBD>ĵ<EFBFBD>%d<><64>IP: %s\n", i+1, inet_ntoa(*(struct in_addr*)host->h_addr_list[i]));
#endif
if (host == NULL || host->h_addr_list == NULL)
return "";
@@ -147,7 +147,7 @@ BOOL IOCPClient::ConnectServer(const char* szServerIP, unsigned short uPort)
(LPTHREAD_START_ROUTINE)WorkThreadProc,(LPVOID)this, 0, NULL);
m_bWorkThread = m_hWorkThread ? S_RUN : S_STOP;
}
std::cout<<"<EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳ɹ<EFBFBD>.\n";
Mprintf("<EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳ɹ<EFBFBD>.\n");
m_bConnected = TRUE;
return TRUE;
}
@@ -174,7 +174,7 @@ DWORD WINAPI IOCPClient::WorkThreadProc(LPVOID lParam)
if (iRet == 0) Sleep(50);
else
{
printf("[select] return %d, GetLastError= %d. \n", iRet, WSAGetLastError());
Mprintf("[select] return %d, GetLastError= %d. \n", iRet, WSAGetLastError());
This->Disconnect(); //<2F><><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(This->m_exit_while_disconnect)
break;
@@ -196,7 +196,7 @@ DWORD WINAPI IOCPClient::WorkThreadProc(LPVOID lParam)
This->OnServerReceiving(szBuffer, iReceivedLength);
if (This->m_Manager!=NULL && This->m_Manager->m_bIsDead)
{
printf("****** Recv bye bye ******\n");
Mprintf("****** Recv bye bye ******\n");
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>˳<EFBFBD><CBB3>ͻ<EFBFBD><CDBB>˺<EFBFBD><CBBA><EFBFBD><EFBFBD>ضˣ<D8B6><CBA3><EFBFBD><EFBFBD>˳<EFBFBD><CBB3>ͻ<EFBFBD><CDBB><EFBFBD>
extern BOOL g_bExit;
g_bExit = This->m_Manager->m_bIsDead;
@@ -271,7 +271,7 @@ VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
m_DeCompressedBuffer.GetBufferLength());
}
else{
printf("[ERROR] uncompress fail: dstLen %d, srcLen %d\n", ulOriginalLength, ulCompressedLength);
Mprintf("[ERROR] uncompress fail: dstLen %d, srcLen %d\n", ulOriginalLength, ulCompressedLength);
delete [] CompressedBuffer;
delete [] DeCompressedBuffer;
throw "Bad Buffer";
@@ -280,17 +280,17 @@ VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
delete [] CompressedBuffer;
delete [] DeCompressedBuffer;
#if _DEBUG
printf("[INFO] uncompress succeed data len: %d expect: %d\n", len, ulPackTotalLength);
// Mprintf("[INFO] uncompress succeed data len: %d expect: %d\n", len, ulPackTotalLength);
#endif
}
else {
printf("[WARNING] OnServerReceiving incomplete data: %d expect: %d\n", len, ulPackTotalLength);
Mprintf("[WARNING] OnServerReceiving incomplete data: %d expect: %d\n", len, ulPackTotalLength);
break;
}
}
}catch(...) {
m_CompressedBuffer.ClearBuffer();
printf("[ERROR] OnServerReceiving catch an error \n");
Mprintf("[ERROR] OnServerReceiving catch an error \n");
}
}
@@ -320,7 +320,7 @@ BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength)
int iRet = compress(CompressedBuffer, &ulCompressedLength, (PBYTE)szBuffer, ulOriginalLength);
if (Z_FAILED(iRet))
{
printf("[ERROR] compress failed \n");
Mprintf("[ERROR] compress failed \n");
delete [] CompressedBuffer;
return FALSE;
}
@@ -412,7 +412,7 @@ BOOL IOCPClient::SendWithSplit(const char* szBuffer, ULONG ulLength, ULONG ulSpl
VOID IOCPClient::Disconnect()
{
std::cout<<"<EFBFBD>Ͽ<EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n";
Mprintf("<EFBFBD>Ͽ<EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n");
CancelIo((HANDLE)m_sClientSocket);
closesocket(m_sClientSocket);