Solved

FTP using wininet.dll lacks timeouts

Posted on 2001-07-14
11
1,193 Views
Last Modified: 2007-11-27
I'm trying to put together a little file downloader app, and I'm having problems reliably downloading and enumerating files.  I am connecting to various FTP servers using wininet.dll, and frequently, i am able to successfully download the file.  Occasionally, the connection process stalls at either FtpFindFirstFile or InternetReadFile.  

The connection will not generate an error message (I waited 10 minutes for one) and yet will not allow the program to continue.  When I pull the cable, the command generate an error after 10 seconds or so about losing it's connection to the internet.  These commands successfully generate an error when I'm not connected to the internet, it is only when they have a chance at a connection that they seem to get stuck.  I can make connections again after disconnecting from the internet and retrying, or after restarting the app.

Is there a way to create a timeout such that the connection will fail and processing will continue?  It looked like InternetSetOption (see MSDN for details) had a INTERNET_OPTION_CONNECT_TIMEOUT
 timeout among many others, but I am having trouble figuring our how to declare the API to be able to test that theory.  (I'm still learning the API stuff).  If anyone could help me with the declarations and stuff, (and it works) i would gladly accept that as an answer.

Is there a way to force a timeout without using InternetSetOption?  The interface is locked-up while I'm waiting, but perhaps there is a way to simulate a network disconnect after a timeout?

Alternatively, is there a way to execute the command in an asynchronous way?  I found details on how to do this in MSDN for C++, but nothing for VB :(  

Finally, am I shooting myself in the foot?  Is FTP through wininet too buggy?  I have seen a bunch of sample code, including the ones from MSDN, but can it be made into releasable quality code?  Can I add enough error handling to make it work?  I don't mind repeatedly attempting the connection, but i can't get around the locked-up program type error that I have now.

Oh, and to save some speedy replys:
No, i can't use OpenURL, so don't copy the sample code here
No, I can't use that ftpGet
both of those commands have been widely panned by people who tried to use them.

If source code would make this clearer, I'd be glad to paste it up here.
0
Comment
Question by:MrBunny
  • 5
  • 5
11 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 6283436
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6283711
I too created an FTP download OCX modelled after Mabry's FTP control (same Properties, Methods and Events).

I therefore find it odd that you would get a timeout when executing FtpFindFirstFile or InternetReadFile.  In my experience this usually happens only when you connect. In any case an error is raised fairly immediately. On the other hand I only connected, downloaded/uploaded and disconnected.

But to answer your question, my understanding is that it is near impossible to write an asynchronous FTP control with the WinInet controls using VB.  There are articles on MSDN that confirm this.

So in conclusion, if this is an exercise and you have plenty of free time than go ahead, however I would strongly recommend you use a commercial control such as Mabry's.
0
 

Author Comment

by:MrBunny
ID: 6283873
Eddy, I checked out that question earlier, and the did fix SOME of the hangups, but i am getting the hangup on a file that i just downloaded 30 seconds earlier, so it's not a machine unavailability issue.

ACPerkins,  I downloaded the Mabry's controls.  Not having to reinvent the wheel sounds like a great idea.  Lemme go make sure it works before I award you the points :P  

0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6286658
I am not after the points, so much as to avoid any unnecessary pain on your part. If it would be of any help I can send you the code I have for the FTP OCX.

Anthony
0
 

Author Comment

by:MrBunny
ID: 6288486
Anthony,

Sample code would be neat!  I've mostly created the application, but there seem to be a few bugs left and perhaps you code could give me some insight.
e-mail: zi3oqz001@sneakemail.com

I am a little new to the Packaging and Deployment wizard, and I must be messing it up somehow because Mabry's controls don't seem to work on the installation destination machine.  I get an error:
Mabry FTP/X Control
Could not create FTP/X COM Object.  Please ensure that FTPX.dll is installed and registered.


I added the FTPX.dll (and the ADO whatever they suggest in thier FAQ) to my installer, and now when i install it on winME machine, it just keeps saying it needs to upgrade everytime i install.  

0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:MrBunny
ID: 6288492
Update:  I installed it on a Win98 machine.... apparently it didn't like the win2k .dll's i had included in it, and I totally hosed the machine.  I fixed it (eventually) by overwriting the .dlls with originals from a clean win98 install.  

I am a little wary now.... can you explain exactly how you are supposed to package the MAbry control?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6290048
Give me a couple of days to package the class up and give you a sample.  For the most part it is pretty straight forward, but the sample would help.

I have never had any problems with installing Mabry controls.  I assume you are using the registered version. If you have any questions, check out their knowledge base. If that does not give you any answers, try emailing them, they have been extremely helpfull in the past, but it has been some years since I needed to contact them.

Anthony
0
 

Author Comment

by:MrBunny
ID: 6290831
Just a quick question, what are you supposed to package?
I got:
ccrpTimr6.dll (a support .dll)
FTPX.dll
FTPX.ocx
QuickDownloader.exe (mine)
setup.exe
setup1.exe
st6unint.exe
VB6 runtime and ole automation
VB6STKIT.dll

When it crashed I had also packaged:
OLE32.dll
ADVAPI32.dll
(because I thought that's what the mabry control required, but my win2k versions seem to have been a bad idea to include).

Does this sound right?  It seems to be working, but...
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6291107
I was just referring to the code (three classes) and the sample.  I can send you the three classes right now if you want and you can let me know if you need samples to see how it works.

Anthony
0
 

Author Comment

by:MrBunny
ID: 6292694
Anthony,

I would love to see your sample code in whatever format is most convenient.  Don't trouble yourself too much with making it run perfectly, i just want to see what patterns you used to do thing.

As a separate question, I am trying to make sure I am packing the Mabry Control properly.  I had never packaged a 3rd party control like Mabry's before, so I am not sure I am doing it right.  I mentioned earlier my list of files that I was including in the packaging, but I wonder if I am missing some, because the Mabry documentation mentions that the control require some support dlls (like OLE32.dll) that I am not including.  This hasn't been a problem so far, perhaps those support .dlls are only needed for win95 machines or something.

If you happen to have ever packaged up an application containing a Mabry control (particularly the FTP one) I would love to see the packing to make sure I am doing it right.

So if you e-mail me your favorite samples I would be much obliged.

-Mr Bunny.  =:x)
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 250 total points
ID: 6299183
I have sent you the code with the three classes.

Regarding Mabry's FTP control, you should be using the FTP/X control which uses the ATL model and unlike their old FTP control it does not require the MFC class DLL's.

Also, I suggest you take a look at the FTP section of their FAQ.  In particular the following question should help:
What are the differences between FTP and FTP/X?
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now