Click to See Complete Forum and Search --> : How to test for network availability prior to CFtpConnection?


Bob Ryan
March 29th, 1999, 08:55 AM
I wrote an application using CInternetSession and CFtpConnection that works very well EXCEPT for when a PC with a network card is disconnected from the network. In this case, it times out eventually -- usually around 4 minutes - but during this lengthy time-out, the application appears hung to the user.


In my CFtpConnection, I'm setting the parameter for the timeout as in:


m_InetSession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, 3000);


I'm guessing I'm mixing concepts: connection timeouts != network timeouts. The question, then, is how can I test to see if a network connection is available prior to making the ftp connection? I tried using winsock2 to essentially ping a host - and ran into the same problem with lengthy timeouts.


Thank you,


Bob

Vijay Kumar C
April 6th, 1999, 08:28 AM
Hi Bob,
I need to code for a FTP client with the same classes, CInternetSession and CFtpConnection.
How did you resolve you problem ? can you please send me the code you used.

I have another problem. I need to show the status on line. The file size, transfer rate, the time remaining etc. How can I get these figures?

My code slice is
////////////////////////////////////////////////
FILE * myfile;
char buf[16];
int count;
CInternetSession mySession("test1");
CFtpConnection * myFtpConnection = mySession.GetFtpConnection("whtorcl","c2032","2032",21,FALSE );
myFtpConnection->SetCurrentDirectory("c2001");
CFtpFileFind myFtpFileFind(myFtpConnection,1);

myFtpFileFind.FindFile("extract.dat");

CInternetFile* iFile = myFtpConnection->OpenFile( "doc.txt",GENERIC_READ, FTP_TRANSFER_TYPE_ASCII,1);

myfile = fopen("download.txt","w");

while( (count = (File->Read( (void* ) buf, 16) ))== 16)
fprintf(myfile,"%s",buf);

fclose(myfile);
AfxMessageBox("Down Load complete");
///////////////////////////////////////////////

Warm Regards,
Vijay