Message Boards Message Boards

0
|
7413 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to test for internet connectivity from within a calculation

Posted 10 years ago

Is there a way to test whether (for desktop Mathematica) in the middle of a calculation whether there is internet connectivity?

The reason is that, if there is no internet connectivity (e.g., WIFI is turned off for the computer) then for my particular application will make use of cached material, but if there is connectivity then I will access the Wolfram knowledge-base.

There is the parameter $AllowInternet which determines whether accessing the internet is permitted, but this is different from determining if the internet is there to use.

POSTED BY: David Reiss
4 Replies

Yes, when I do a ping in the terminal on OS X it runs without stopping until I do a control-c.

POSTED BY: David Reiss
Posted 10 years ago
POSTED BY: Bill Simpson

Hmmmm... if I turn off my WIFI I get:

In[3]:= Run["ping Google.com"]

Out[3]= 17408

But if I have it on, when I execute

Run["ping Google.com"]

it does not terminate and locks up the Kernel. Usually when one does a ping in a terminal it is a process that continues until one executes a control-c. I had to Kill my Mathematica to continue... the usual attempt to abort does not work in this case. So perhaps this is not quite a usable. ;-)

POSTED BY: David Reiss
Posted 10 years ago
Run["ping some.domain.name"]

seems to either return a 0 if it successfully gets a ping response or 1 if it fails.

POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract