Socket problem ?
C / C++ / MFC
1
Posts
1
Posters
0
Views
1
Watching
-
In MSDN, I found a samples: ChatSvr and Chatter. That is a network application using CSocket. But I don't know how to use CSocket in multithread. In ChatSvr, I want to throw each client connecting to server to a particular thread. It means server will manage each client ( and his socket) in 1 thread. How can I do that ? I imagine the code for solving this problem may be like this: void CServerDoc::ProcessPendingAccept() { CClientSocket* pSocket = new CClientSocket(this); if (m_pSocket->Accept(*pSocket)) { pSocket->Init(); m_connectionList.AddTail(pSocket); //Add this line: m_threadList.Add(....); //or AfxBeginThread(....); } else delete pSocket; } Hung Son A Vietnamese student i-g.hypermart.net dlhson2001@yahoo.com