Socket connection passing

I have an existing socket which connects to the server when I click call.

it is declared as CSocket Confcall;.

then i will use hConf=Confcall.detach();

and send it to the thread using AfxBeginThread(SocketThreadProc,this,THREAD_PRIORITY_NORMAL,0,0,NULL);



the thread is like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

UINT CTabDlg::SocketThreadProc(LPVOID pParam)
{
	SOCKET tem;
	CString bufCheck;
        CSocket abc;
	CTabDlg* pThis = (CTabDlg*)pParam;
	tem = pThis->hConf;
	abc.Attach(tem);
	char echoBuffer[1024];
	for (;;)
	{
		abc.Receive(echoBuffer,1024,0);
		for(int i=0;i<5;i++)
			bufCheck+=echoBuffer[i];
		if(bufCheck == "CNF N")
			pThis->updateParticipantStatus(echoBuffer);
		if(pThis->killThread == true)
			return true;
	}
 return true;
}

 


It gives me an assertion at this line



abc.Attach(tem);


it points to the ensure(this) of this function





void* CMapPtrToPtr::GetValueAt(void* key) const
// find value (or return NULL -- NULL values not different as a result)
{
ENSURE(this);

any ideas?
I've never used CSocket, but what is the value of tem in abc.Attach(tem);?
i solved it with CAsyncSocket
Topic archived. No new replies allowed.