IT Community - Software Programming, Web Development and Technical Support

VC++ Problems & Solutions

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 ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C and C++ Programming

Register FAQ Members List Calendar Mark Forums Read
  #1  
Old 03-01-2007, 08:38 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 301
Karpagarajan is on a distinguished road
Thumbs up VC++ Problems & Solutions

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 04-10-2007, 02:36 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 301
Karpagarajan is on a distinguished road
Thumbs up Re: VC++ Problems & Solutions

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
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT


thanks
__________________
Karpagarajan. R
Necessity is the mother of invention
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
What are the solutions for subdomain SSL Cetificates? Olaf General Web hosting Discussions 3 01-09-2009 04:23 AM
Javascript Common issues / problems and solutions . a.deeban HTML, CSS and Javascript Coding Techniques 2 09-14-2007 12:14 AM
Difference Between Focusing On Problems And Focusing On Solutions vadivelanvaidyanathan The Lounge 1 09-02-2007 11:07 PM
What are 5 common solutions to software development problems? devarajan.v Software Testing 1 07-17-2007 07:12 AM
eCommerce solutions drecko eCommerce 5 03-14-2007 05:55 PM


All times are GMT -7. The time now is 03:52 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0