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 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 03-01-2007, 09:38 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 299
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
Sponsored Links
  #2 (permalink)  
Old 04-10-2007, 03:36 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 299
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 On
Pingbacks are On
Refbacks are On

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


All times are GMT -7. The time now is 05:38 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0