CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Many Sockets

  1. #1
    Join Date
    Jul 2005
    Posts
    266

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

  2. #2
    Join Date
    Apr 2005
    Location
    Norway
    Posts
    3,934

    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

  3. #3
    Join Date
    Feb 2002
    Posts
    4,640

    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

  4. #4
    Join Date
    Jul 2005
    Posts
    266

    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.

  5. #5
    Join Date
    Apr 2005
    Location
    Norway
    Posts
    3,934

    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

  6. #6
    Join Date
    May 2001
    Location
    Germany
    Posts
    1,158

    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
  •  





Click Here to Expand Forum to Full Width

Featured