Page 1 of 1

How to check internet connection without error message?

Posted: Mar 31st, '18, 13:30
by MSandro
Hi, I am working on a project which should access some files in the internet, so I would like to have a sort of "connection-test" to prevent the "unknown host" error to appear. How could I do that?

Thank you very much.

Re: How to check internet connection without error message?

Posted: Jul 20th, '18, 18:00
by Calloway
Using an if-else maybe?... I don't know, you could try using cloud variables?

Re: How to check internet connection without error message?

Posted: Jul 22nd, '18, 21:21
by JohnM
Check out the "safelyRun" function in tasks.gp.

That will allow you to try to open a socket to a given host. If you provide an error function, it will be called if the attempt fails. Or, if you don't provide an error function, you'll get a Task object back if it fails or an ExternalReference back if it succeeds. So you can check the class of the returned value to figure out what happened.