The information in this article applies to:
SYMPTOMSWhen using MFC sockets in secondary threads in a statically linked MFC Visual C++ 6.0 application, an unhandled exception occurs. CAUSEThe reason for the unhandled exception is that an object of type CMapPtrToPtr pointer, pointed to by m_pmapSocketHandle, is never created. RESOLUTIONThe handle maps used by the sockets need to be created for each thread. The following code shows a function to do this:
This function should be called once in each secondary thread before the
first socket is created in the new thread.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. Q194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why Q194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed MORE INFORMATIONIn MFC socket applications, AfxSocketInit is called once, by default, in the primary thread. This function creates the handle maps for the primary thread when statically linked to MFC. However, when a secondary thread is created, these per-thread handle maps are not created. AfxSocketInit must be called in each thread to initialize the socket libraries. Steps to Reproduce Behavior
REFERENCESFor additional information, please see the following article in the Microsoft Knowledge Base: Q175668 FILE: MultiSoc: Illustrates Using Sockets in Multiple Threads © Microsoft Corporation 1998, All Rights Reserved. Additional query words: LookupHandle CAsyncSocket AttachHandle GetValueAt assert wincore.cpp 980 Application Error 0xc0000005 m_pHashTable CSocket access violation debug assertion failed
Keywords : kbservicepack kbMFC kbVC600bug kbWinsock kbVS600sp2 kbVS600SP1 kbVS600sp3fix |
Last Reviewed: July 8, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |