Help me plz!!!!!
I passed the socket to my thread but it can't receive any message!!!!!!!!!!!
Did I do something wrong?
I have a main class CServerDlg which accepts the socket connection in this method.
void CServerDlg:
rocessPendingAccept()
{
CClientConnSocket* socClientConn = new CClientConnSocket();
if (m_socListening->Accept(*socClientConn))
{
SOCKET hSocClientConn = socClientConn->Detach();
CServerChild* threadServerChild = new CServerChild(this, hSocClientConn);
threadServerChild->CreateThread()
}
}
Class CServerChild ,extends from CWinThread, has the constructor and InitInstance() like this :-
CServerChild::CServerChild(CServerDlg* pDoc, SOCKET hSocClientConn)
{
m_hSoc = hSocClientConn;
m_pDoc = pDoc;
}
BOOL CServerChild::InitInstance()
{
m_socClientConn = new CClientConnSocket();
m_socClientConn->Attach(m_hSoc);
m_socClientConn->Init(this);
m_pFile = new CSocketFile(m_socClientConn);
m_pArchiveIn = new CArchive(m_pFile,CArchive::load);
m_pArchiveOut = new CArchive(m_pFile,CArchive::store);
return CWinThread::InitInstance();
}
I passed the socket to my thread but it can't receive any message!!!!!!!!!!!
Did I do something wrong?
I have a main class CServerDlg which accepts the socket connection in this method.
void CServerDlg:
{
CClientConnSocket* socClientConn = new CClientConnSocket();
if (m_socListening->Accept(*socClientConn))
{
SOCKET hSocClientConn = socClientConn->Detach();
CServerChild* threadServerChild = new CServerChild(this, hSocClientConn);
threadServerChild->CreateThread()
}
}
Class CServerChild ,extends from CWinThread, has the constructor and InitInstance() like this :-
CServerChild::CServerChild(CServerDlg* pDoc, SOCKET hSocClientConn)
{
m_hSoc = hSocClientConn;
m_pDoc = pDoc;
}
BOOL CServerChild::InitInstance()
{
m_socClientConn = new CClientConnSocket();
m_socClientConn->Attach(m_hSoc);
m_socClientConn->Init(this);
m_pFile = new CSocketFile(m_socClientConn);
m_pArchiveIn = new CArchive(m_pFile,CArchive::load);
m_pArchiveOut = new CArchive(m_pFile,CArchive::store);
return CWinThread::InitInstance();
}