|
-
December 20th, 2005, 12:16 PM
#1
Many Sockets
Ok i need to have at least 5-6 sockets for different things opened in my program. The problem is when i use pointers i get stack overflow errors. When i don't use pointers i get some other errors.
How can i fix that>?
-
December 20th, 2005, 02:46 PM
#2
Re: Many Sockets
Ok i need to have at least 5-6 sockets for different things opened in my program.
IMO that is not that 'many sockets'. 'Many sockets' are more like hundreds, or thousands.
The problem is when i use pointers i get stack overflow errors. When i don't use pointers i get some other errors.
Sound like a function is calling itself repeatedly...until it crashes (that is just a wild guess).
I think you need to show some code.
- petter
-
December 20th, 2005, 05:54 PM
#3
Re: Many Sockets
As Wildfrog said, it sounds like you might have some kind of construction recursion going on, but that's just a guess. Show some code, and maybe we can help!
Viggy
-
December 21st, 2005, 02:16 AM
#4
Re: Many Sockets
Ok i have this class
CTunel.
class CTunel : public CAsyncSocket
{
public:
CTunel();
virtual ~CTunel();
public:
virtual void OnReceive(int nErrorCode);
public:
virtual void OnAccept(int nErrorCode);
};
it's construction is
CWoWTunelDlg *dlg=NULL;
CTunel::CTunel()
{
if(dlg != NULL)
{
delete dlg;
dlg = NULL;
}
dlg = new CWoWTunelDlg;
}
but when i my dialog class i have CTunel* listener1;
and i make
listener1=NULL;
listener1 = new CTunel; boom -> memory leak
i also have some other memory leaks where the lines that they occur are not referenced...
so this is my memory leak dump
Dumping objects ->
{76} client block at 0x00B963C0, subtype c0, 4244 bytes long.
a CDialog object at $00B963C0, 4244 bytes long
wowtuneldlg.cpp(100) : {75} client block at 0x00B96378, subtype c0, 8 bytes long.
a CAsyncSocket object at $00B96378, 8 bytes long
Object dump complete.
I think this is because i haven't deleted my pointers but i need them to be there while this program is on. I mean i can't delete em
Last edited by kolkoo; December 21st, 2005 at 02:23 AM.
-
December 21st, 2005, 04:02 AM
#5
Re: Many Sockets
You should post enough code to reproduce the problem (possibly attach you whole project w/o binaries).
I think this is because i haven't deleted my pointers but i need them to be there while this program is on. I mean i can't delete em
Well, you can and you should delete them when you're done with em.
- petter
-
December 21st, 2005, 11:40 AM
#6
Re: Many Sockets
Do I get this right? You have a dialog object of class CWoWTunelDlg and inside it you create a CTunel object which in turn deletes a CWoWTunelDlg object and creates a new one?
Are you sure you are not deleting the actual object? It might be that you delete it (thus invalidating it) and then try to continue to use it.
Richard
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
|