|
-
November 12th, 2008, 02:56 AM
#1
ASSERT(m_hSocket == INVALID_SOCKET) Error
Hello MFC networking gurus. i'm having some trouble in my program. It generates an access violation runtime error and when i debug it, it points to the assertion in the title.
it's a client based CSocket Application where all i did was follow the normal flow.
1. AfxSocketInit()
2. CreateSocket();
3. Connect();
the error occurs in the create part.
a little detailed design of the program is:
Code:
class CSockMgrDLGDlg : public CDialog
{
//other functions and attributes
private:
CommunicationMgr *oComMgr;
};
class CommunicationMgr
{
//other functions and attributes
private:
CSocketMgr *oSocketMgr;
}
class CSocketMgr : public CSocket
{
//some functions and attributes
};
CSockMgrDLGDlg uses CommunicationMgr for connectivity. CSockMgrDLGDlg calls the CommunicationMgr::Connect() function
and CommunicationMgr::Connect calls CSocket::Connect() that goes for XXX::Create() too.
Question:
1. what do you think are the possible reasons that this access violation error is occurring?
2. will there be some hidden bugs/runtime errors created if CSockMgrDLGDlg doesn't use CSocketMgr directly?
thank you very much in advance..
Last edited by klambiguit; November 12th, 2008 at 05:17 AM.
Reason: added details..
-
November 12th, 2008, 05:09 AM
#2
Re: ASSERT(m_hSocket == INVALID_SOCKET) Error
A possible reason for this is something you do in your code. Which, unfortunately, you did not post, so there is pretty little anybody can say about this case.. Please post the relevant code (and please do use code tags).
-
November 12th, 2008, 05:25 AM
#3
Re: ASSERT(m_hSocket == INVALID_SOCKET) Error
-
November 12th, 2008, 08:53 AM
#4
Re: ASSERT(m_hSocket == INVALID_SOCKET) Error
found it!! thanks!!
it was a stupid mistake..!
there are two constructors in CCommunicationMgr Class.
what i've used is the default constructor w/c does not instantiate the CSocketMgr class w/c is why there is an access violation.. :sigh:
the other constructor instantiates the CSocketMgr Class.
-
November 12th, 2008, 09:12 AM
#5
Re: ASSERT(m_hSocket == INVALID_SOCKET) Error
a follow up question, everything works fine now.. my client can connect but after connection, why does it consume sooooo much memory? i can't detect the leak.. please help...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|