FTP Download And Stack Overflow

This is a discussion on FTP Download And Stack Overflow within the Windows Programming forums, part of the Platform Specific Boards category; I have a worker thread which I start with AfxBeginThread. This threads tries to download a file from FTP but ...

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    18

    FTP Download And Stack Overflow

    I have a worker thread which I start with AfxBeginThread. This threads tries to download a file from FTP but when it hits the GetFile function it causes a stack overflow and Visual Studio disappears. The code (abridged) is below:

    Code:
    		ftpConn = session.GetFtpConnection("*****","*****","*****"); 
    		
    		if(ftpConn != NULL) 
    		{ 
    			if(ftpConn->SetCurrentDirectory("/") != 0) 
    			{ 
    				if(ftpConn->GetFile(strRemoteFile, strLocalFile, FALSE) == 0) 
    				{
    				}
    			}
    
    			ftpConn->Close();
    			delete ftpConn;
    		}
    
    		session.Close();
    Any ideas what is causing it?

  2. #2
    Registered User
    Join Date
    Nov 2010
    Posts
    18
    I seem to have fixed this. I was creating the thread in the OnInitDialog of my CDialog derived class. Doing so causes a stack overflow in the thread. However, if I start the thread after OnInitDialog has finished, there is no stack overflow.

    I am a little surprised that I can't start it in OnInitDialog (I would expect to be able to) but at least it is fixed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My little stack library - what do you think?
    By hauzer in forum C Programming
    Replies: 6
    Last Post: 10-17-2008, 09:01 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21