This is a discussion on VC++ Problems & Solutions within the C and C++ Programming forums, part of the Software Development category; Hi all, I am going to give the VC++ problems & solutions in this thread. If you have any problem ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi all, I am going to give the VC++ problems & solutions in this thread. If you have any problem while coding in VC++, you can place your questions here. When I was working in VC++ for socket programming, I have faced lot of problems in sockets. One of the big problem in socket programming is when I was using the socket in the multithreadding functionality, I have faced unhandled exception error. I have faced the following problem, and after lot of searching through web I found the solution. I have mentioned the problem and solution here. SYMPTOMS When using MFC sockets in secondary threads in a statically linked MFC Visual C++ 6.0 application, an unhandled exception occurs. CAUSE The reason for the unhandled exception is that an object of type CMapPtrToPtr pointer, pointed to by m_pmapSocketHandle, is never created. RESOLUTION The handle maps used by the sockets need to be created for each thread. The following code shows a function to do this: void SocketThreadInit() { #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 } This function should be called once in each secondary thread before the first socket is created in the new thread. thanks
__________________ Karpagarajan. R Necessity is the mother of invention |
| Sponsored Links |
| |||
| Hi, When I was doing the Composite control in ATL, I have faced the problem ATL - Composite control - Cannot include the class from the CTreeCtrl. I couldnt point out the error why it was occured and after long debugging, I have found out the solution. Solution is to include the following sentence to the "Stdafx.h" #ifndef _AFX_NO_AFXCMN_SUPPORT thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
![]() |
| Thread Tools | |
| Display Modes | |
| |
LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/c-c-programming/346-vc-problems-solutions.html | |||
| Posted By | For | Type | Date |
| Digg - VC++ Problems&Solutions | This thread | Refback | 07-20-2007 03:10 AM |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Networking problems | ventyra | Networking & Internet Connectivity | 0 | 12-05-2007 02:07 AM |
| Javascript Common issues / problems and solutions . | a.deeban | HTML, CSS and Javascript Coding Techniques | 2 | 09-14-2007 01:14 AM |
| Difference Between Focusing On Problems And Focusing On Solutions | vadivelanvaidyanathan | The Lounge | 1 | 09-03-2007 12:07 AM |
| What are 5 common solutions to software development problems? | devarajan.v | Software Testing | 1 | 07-17-2007 08:12 AM |
| eCommerce solutions | drecko | eCommerce | 5 | 03-14-2007 06:55 PM |