Click to See Complete Forum and Search --> : Many Sockets


kolkoo
December 20th, 2005, 11:16 AM
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>?

wildfrog
December 20th, 2005, 01:46 PM
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

MrViggy
December 20th, 2005, 04:54 PM
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

kolkoo
December 21st, 2005, 01:16 AM
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 :(

wildfrog
December 21st, 2005, 03:02 AM
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 emWell, you can and you should delete them when you're done with em.

- petter

Richard.J
December 21st, 2005, 10:40 AM
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