Prev: Tamper-proof way of storing files external to exe (images, configuration files etc)
Next: MS video control (msvidctl) to implement digital tv (dmb-th) with
From: will_456 on 2 Nov 2009 16:02 My program uses an inet control to check for a new version on the server. Trouble is (occasionally) the users Internet connection is very weak or they close the program immediately on startup while the control is still connecting. I have this code in the form unload to close down the connection - inetFTP.Execute , "CLOSE" It works, but if the Internet is very slow the program hangs and wont close until the command to be sent and received. Is there a way to terminate it instantly? I've tried using various timeouts but they don't help as you still need to wait.
From: Nobody on 2 Nov 2009 16:56 "will_456" <will_456(a)nospam.com> wrote in message news:ENHHm.51674$ze1.35856(a)news-server.bigpond.net.au... > My program uses an inet control to check for a new version on the server. > Trouble is (occasionally) the users Internet connection is very weak or > they close the program immediately on startup while the control is still > connecting. > > I have this code in the form unload to close down the connection - > inetFTP.Execute , "CLOSE" > > It works, but if the Internet is very slow the program hangs and wont > close until the command to be sent and received. > > Is there a way to terminate it instantly? > I've tried using various timeouts but they don't help as you still need to > wait. In MSDN Library Oct 2001, look for article Q176420. In particular, a note at the end. Her is a quote: <Quote> * INTERNET_OPTION_RECEIVE_TIMEOUT no longer works in Internet Explorer 5.0. For more information, see the following article in the Microsoft Knowledge Base: Q224318 HOWTO: Control Connection Timeout Value by Creating Second Thread * The latest version of the Wininet.dll file that shipped with Internet Explorer 5.01 (available for download) fixes all timeout problems for HTTP APIs only. FTP timeouts still cannot be changed. <End Quote> So here are some options: 1 - Look for FTP code that is not based on WinInet API. You can find some at http://www.planet-source-code.com/ FTP protocol is "simple" to implement. 2 - Use a commercial solution, such as: http://www.catalyst.com/products/filetransfer/index.html 3 - Use WinInet API directly, and put the code in ActiveX EXE and enable "Thread per Object". This ActiveX would do all the FTP/HTTP work. For example, you could methods like StartConnect, StartDownload, and add events like ConnectComplete, DownloadComplete, so your standard VB app is not tied in a loop. Whenever you want to timeout an operation from your Standard EXE, you call InternetCloseHandle() to close the handle used by the ActiveX EXE(As shown in article Q224318). This terminates any pending Connect or lengthy operations. Here are some samples that shows how to use the WinInet API directly: SAMPLE: Vbhttp.exe Demonstrates How to Use HTTP WinInet APIs in Visual Basic http://support.microsoft.com/kb/259100/en-us SAMPLE: VBFTP.EXE: Implementing FTP Using WinInet API from VB http://support.microsoft.com/kb/175179/en-us SAMPLE: Using FTP WinInet APIs in Visual Basic with SimpleFtp http://support.microsoft.com/kb/195653/en-us
From: Larry Serflaten on 2 Nov 2009 20:05
"will_456" <will_456(a)nospam.com> wrote > My program uses an inet control to check for a new version on the > server. Trouble is (occasionally) the users Internet connection is very > weak or they close the program immediately on startup while the control > is still connecting. > > I have this code in the form unload to close down the connection - > inetFTP.Execute , "CLOSE" > > It works, but if the Internet is very slow the program hangs and wont > close until the command to be sent and received. > > Is there a way to terminate it instantly? > I've tried using various timeouts but they don't help as you still need > to wait. Did you try the Cancel method? LFS |