forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using DOWNLOAD@

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
wahorger



Joined: 13 Oct 2014
Posts: 739
Location: Morrison, CO, USA

PostPosted: Mon Jan 27, 2020 4:38 am    Post subject: Using DOWNLOAD@ Reply with quote

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
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6321
Location: Salford, UK

PostPosted: Mon Jan 27, 2020 9:28 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6321
Location: Salford, UK

PostPosted: Mon Jan 27, 2020 8:04 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 739
Location: Morrison, CO, USA

PostPosted: Mon Jan 27, 2020 9:34 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6321
Location: Salford, UK

PostPosted: Tue Jan 28, 2020 10:04 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 739
Location: Morrison, CO, USA

PostPosted: Tue Jan 28, 2020 2:08 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6321
Location: Salford, UK

PostPosted: Tue Jan 28, 2020 3:31 pm    Post subject: Reply with quote

Yes. That's right.
Back to top
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 739
Location: Morrison, CO, USA

PostPosted: Tue Jan 28, 2020 10:14 pm    Post subject: Reply with quote

Great! Thanks so much, Paul!
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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