Click to See Complete Forum and Search --> : VC6"s problem


Sunway xiao
March 29th, 1999, 08:56 AM
hi:

Environment : Windows 95/NT, Visual C++ 6.0 SP2

i am developing a soft. In this software, i create one prime thread, and another thread.

In one thread( no prime ) I create a CSocket . I use following code.

BOOL CPopListThread::CreatePop3Server()

{

m_pPop3Server = new CPop3Socket();

if( m_pPop3Server == NULL )

return FALSE;

ASSERT_VALID( m_pPop3Server );

m_pPop3Server->Create();

return TRUE;

}

CPop3Socket inherit class 'CAsyncSocket'

When i build application with 'Use MFC in a Shared Dll' mode ,

the application is working perfectly.but when i build application

with ''Use MFC in a Static Dll' mode ,it is aborted. I find the following

code cause error.

m_pPop3Server->Create();

but I build application by VisualC++ 5.0 . it is no any error. why!!??



Thanks in advance


Regards

Sunway Xiao

Donald Conner
March 30th, 1999, 07:23 AM
The lies in a bug with the bowels of the code. It is a microsoft problem if you apply the following code in the InitInstance of your non-primary thread it should fix it.


#ifndef _AFXDLL

#define _AFX_SOCK_THREAD_STATE AFX_MODULE_THREAD_STATE

#define _afxSockThreadState AfxGetModuleThreadState()


_AFX_SOCK_THREAD_STATE *pState = _afxSockThreadState;

if(pState->m_pmapSocketHandle == NULL)

pState->m_pmapSocketHandle = new CMapPtrToPtr;

if(pState->m_pmapDeadSockets == NULL)

pState->m_pmapDeadSockets = new CMapPtrToPtr;

if (pState->m_plistSocketNotifications == NULL)

pState->m_plistSocketNotifications = new CPtrList;

#endif


Hope this helps you. If you have further question lemme know.


The_Merlin@osc.com