mirror of
https://github.com/yuanyuanxiang/SimpleRemoter.git
synced 2026-01-21 23:13:08 +08:00
style: Change files encoding format to UTF8-BOM
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
#include "IOCPUDPServer.h"
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
@@ -37,17 +37,17 @@ UINT IOCPUDPServer::StartServer(pfnNotifyProc NotifyProc, pfnOfflineProc OffProc
|
||||
|
||||
m_running = true;
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
// 启动工作线程
|
||||
m_hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)+[](LPVOID param) -> DWORD {
|
||||
((IOCPUDPServer*)param)->WorkerThread();
|
||||
return 0;
|
||||
}, this, 0, NULL);
|
||||
|
||||
// <EFBFBD>ύ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// 提交多个初始接收
|
||||
for (int i = 0; i < 4; ++i)
|
||||
PostRecv();
|
||||
|
||||
return 0; // <EFBFBD>ɹ<EFBFBD>
|
||||
return 0; // 成功
|
||||
}
|
||||
|
||||
void IOCPUDPServer::PostRecv()
|
||||
@@ -111,12 +111,12 @@ void IOCPUDPServer::WorkerThread()
|
||||
if (999 != ret)
|
||||
ctx->Destroy();
|
||||
|
||||
// <EFBFBD>ͷ<EFBFBD>
|
||||
// 释放
|
||||
ioCtx->pContext = NULL;
|
||||
delete ioCtx;
|
||||
DelCount();
|
||||
|
||||
PostRecv(); // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύ
|
||||
PostRecv(); // 继续提交
|
||||
}
|
||||
SAFE_CLOSE_HANDLE(m_hThread);
|
||||
m_hThread = NULL;
|
||||
@@ -158,7 +158,7 @@ BOOL IOCPUDPServer::Send2Client(CONTEXT_OBJECT* ContextObject, PBYTE szBuffer, U
|
||||
VOID IOCPUDPServer::Destroy()
|
||||
{
|
||||
if (m_socket != INVALID_SOCKET) {
|
||||
CancelIoEx((HANDLE)m_socket, NULL); // ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CancelIoEx((HANDLE)m_socket, NULL); // 取消所有IO请求
|
||||
closesocket(m_socket);
|
||||
m_socket = INVALID_SOCKET;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ VOID IOCPUDPServer::Destroy()
|
||||
Sleep(200);
|
||||
|
||||
m_running = false;
|
||||
PostQueuedCompletionStatus(m_hIOCP, 0, 0, NULL); // <EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><EFBFBD>˳<EFBFBD>
|
||||
PostQueuedCompletionStatus(m_hIOCP, 0, 0, NULL); // 用于唤醒线程退出
|
||||
|
||||
if (m_hThread) {
|
||||
WaitForSingleObject(m_hThread, INFINITE);
|
||||
|
||||
Reference in New Issue
Block a user