CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: VC6"s problem

  1. #1
    Join Date
    Mar 1999
    Posts
    2

    VC6"s problem



    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

  2. #2
    Join Date
    Mar 1999
    Posts
    1

    Re: VC6"s problem



    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.


    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured