原来的代码:
线程函数 ---
UINT ServerRecThread(LPVOID pParam) { SOCKET sRecSocket = (SOCKET)pParam; while(1) { if(CServerObj.RecClient(sRecSocket)) break; } return 0; }
调用线程函数 ----
AfxBeginThread(ServerRecThread,(void *)m_SClient);
为了不使用MFC库, 需要把 AfxBeginThread 用 CreateThread 替换 , 做如下修改 ----
线程函数 ---
DWORD WINAPI ServerRecThread32(LPVOID pParam)
{
SOCKET sRecSocket = (SOCKET)pParam;
while(1)
{
if(CServerObj.RecClient(sRecSocket))
break;
}
return 0;
}
调用 ----
CreateThread( NULL, 0, ServerRecThread32,(LPVOID)m_SClient, 0, NULL);