Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting and Deleting files from ftp server using MFC WinInet class

32 views
Skip to first unread message

jettaime

unread,
Mar 15, 2007, 8:54:08 AM3/15/07
to
Hi~,
I developed my application to getting files from ftp server using MFC
WinInet classes. The flow is like this,
...........................
// create session
CInternetSession session;

// set timeout option
session.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,60000);// 60 sec
session.SetOption(INTERNET_OPTION_RECEIVE_TIMEOUT,10000);// 10 sec
session.SetOption(INTERNET_OPTION_SEND_TIMEOUT,10000);// 10 sec

// connect to ftp server
CFtpConnection* pFtpConnection = session.GetFtpConnection(...);

// find file from directory 1
CFtpFileFind finder1(pFtpConnection);
BOOL bWorking = finder1.FindFile("/directory1/*");
while(bWorking)
{
bWorking = finder1.FindNextFile();
src = finder1.GetFineName();
dst = ....;
pFtpConnection->GetFile(src,dst,,,,FTP_TRANSFER_TYPE_BINARY,1);
}
finder1.Close();

// find file from directory 2
CFtpFileFind finder2(pFtpConnection);
BOOL bWorking = finder2.FindFile("/directory2/*");
while(bWorking)
{
bWorking = finder2.FindNextFile();
src = finder2.GetFineName();
dst = ....;
pFtpConnection->GetFile(src,dst,,,,FTP_TRANSFER_TYPE_BINARY,1);
}
finder2.Close();

pFtpConnection->Close();
delete pFtpConnection;
pFtpConnection = NULL;
session.Close();
....................................
I run above every minute for testing by looping.
When normal case, everything is ok. But, when the timeout is occurred caused
by network problems, there are some problems like this.
1. Microsoft windows XP sp2 firewall service is stopped. And I could not
start its service.
2. "Generic Host Process for Win32 Services" error message box appeared.
3. Incomming traffic is blocked.

I'm afraid whether my code has bugs, so when network problem occurred,
resources leak.....
I can't find out the solution.

Please someone help me.

--
--------------------------------------------
developer...
--------------------------------------------

0 new messages