|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Mon Jan 27, 2020 4:38 am Post subject: Using DOWNLOAD@ |
|
|
Is there a way to set the timeout value for using DOWNLOAD@? Specifically, if there is no response within some user specified time period, the function returns a non-zero result? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Mon Jan 27, 2020 9:28 am Post subject: |
|
|
I can't see anything within DOWNLOAD@ that refers to a timeout value.
Information about web routines can be found in ftn95.chm under ClearWin+->Hypertext windows->Linking to the web.
Here is a list of the actions and Windows API functions that are called by DOWNLOAD@ together with the associated error values upon failure....
Call InternetOpen (error = 2)
Call InternetOpenUrl (error = 3) uses INTERNET_FLAG_DONT_CACHE
Allocate memory (error = 4)
Call InternetReadFile (error = 5)
Copy data to memory (error = 1)
Successful finish (error = 0) |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Mon Jan 27, 2020 8:04 pm Post subject: |
|
|
It looks like the Windows API function InternetSetOptionA might do the trick but it would need to be called from within DOWNLOAD@.
The possible parameters are INTERNET_OPTION_CONNECT_TIMEOUT, INTERNET_OPTION_RECEIVE_TIMEOUT, and INTERNET_OPTION_DATA_RECEIVE_TIMEOUT.
I can add this to the wishlist if you think that it might be useful.
A new routine SET_INTERNET_TIMEOUT@(PARAM, TIME) could be created where PARAM is one of the above parameters and TIME is the new timeout in milliseconds. The routine would be called before calling DOWNLOAD@ and would work equally well with other routines such as READ_URL@. |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Mon Jan 27, 2020 9:34 pm Post subject: |
|
|
Paul, I'll tell you my situation, and perhaps it might apply to others.
My internet provider (wireless point-to-point) has an interference problem that manifests itself by causing my connection to fail, sometimes for many, many seconds, up to the minutes. Annoying, unpredictable, not productive, but not task killing (usually).
So, when I am testing my SW, starting it up perhaps dozens of times in an hour, it will "hang up" because one thing it does at the start, every time, is send out a request to my site for the latest version number.
If I have disconnected my internet cable, the return is nearly immediate because there is no connection versus this, a faulty connection. It has been bugging me for months why I get these delays.
I am thinking of adding a feature that would utilize the DOWNLOAD@ functionality but be used rarely. If this new feature delays execution, no big deal.
I'll leave it up to you. It would be nice to be able to set the timeout to, for example, 1.5 seconds while the splash screen is being displayed, but is not a fault that needs to be remedied.
Bill |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Tue Jan 28, 2020 10:04 am Post subject: |
|
|
I have added two new routines SET_INTERNET_CB@ and SET_INTERNET_PARAM@. The first sets a callback function. The second is designed to be called from within this callback. Here is an illustration of how it will work...
Code: | INCLUDE <clearwin.ins>
INTEGER err,fileSize
INTEGER(7)handle
CHARACTER(80) url
INTEGER,EXTERNAL::cb
url = "http://forums.silverfrost.com/viewtopic.php?t=4130"
err = 0
fileSize = 0
handle = DOWNLOAD@(url, fileSize, err)
IF(err > 0) STOP 'Download failed'
PRINT*, "File size is", fileSize
fileSize = fileSize + 4
CALL SET_INTERNET_CB@(cb)
handle = DOWNLOAD@(url, fileSize, err)
DO i=0,20
PRINT*, CCORE1(handle+i)
ENDDO
END
INTEGER FUNCTION cb()
INCLUDE <clearwin.ins>
INTEGER,PARAMETER:: INTERNET_OPTION_CONNECT_TIMEOUT=2
INTEGER ans
!Set connection timeout to 70 seconds.
ans = SET_INTERNET_PARAM@(INTERNET_OPTION_CONNECT_TIMEOUT,70000)
PRINT*, "Previous timeout was", ans, " milliseconds"
cb = 1
END FUNCTION cb |
If the value (2nd argument) in SET_INTERNET_PARAM@ is zero then the current value is returned without being set. |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Tue Jan 28, 2020 2:08 pm Post subject: |
|
|
Paul, I think this would work marvelously!
So, for each use of download@(), one sets the callback routine that applies, then in download@(), the callback applies the change in the parameter at the appropriate time, yes? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Tue Jan 28, 2020 3:31 pm Post subject: |
|
|
Yes. That's right. |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Tue Jan 28, 2020 10:14 pm Post subject: |
|
|
Great! Thanks so much, Paul! |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|