From ripley at stats.ox.ac.uk  Fri Jun 22 14:11:11 2007
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Fri, 22 Jun 2007 13:11:11 +0100 (BST)
Subject: [Rd] Cross-platform check for internet connection
In-Reply-To: <f8e6ff050706220446i39d2222cqb9f30c38f93f2066@mail.gmail.com>
References: <f8e6ff050706220114gb008b92ib58e151e4742f774@mail.gmail.com> 
	<Pine.LNX.4.64.0706221117520.21000@gannet.stats.ox.ac.uk>
	<f8e6ff050706220446i39d2222cqb9f30c38f93f2066@mail.gmail.com>
Message-ID: <Pine.LNX.4.64.0706221304410.394@gannet.stats.ox.ac.uk>

On Fri, 22 Jun 2007, hadley wickham wrote:

> On 6/22/07, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:
>> On Fri, 22 Jun 2007, hadley wickham wrote:
>> 
>> > What's the recommended way to check if an internet connection is
>> > available across platforms?  I was using is.null(nsl()) but this does
>> > not work on windows.
>> 
>> I don't know a way to do this on Windows without a possible very long
>> hang.  It's complicated by the use of two alternative internet connection
>> mechanisms on Windows and having little control over the IE-based one.
>> 
>> Another issue is software firewalls: they can take many minutes to
>> decide to let a new program talk to the Internet if they 'call home' to
>> ask advice.
>
> Thanks for those details, I hadn't considered the problems that might
> be associated with firewalls.
>
> To give a little more context, I have an example in one of my packages
> which downloads some data off the web.  I don't really want to include
> the data in my package, since it's not my data (although I'm fairly
> certain I could get permission to include it).

There are several packages on CRAN which do that.  Some do take a long 
time, and as a result are only partially checked.  If I recall right, 
'celsius' is an example on the stoplist (it takes many tens of minutes to 
get its data) and 'tseries' and a couple more fail occasionally when the 
data are not available in time.

> So really it doesn't matter if there will be a long delay, provided
> that there won't be a long delay for the windows CRAN server.  I could
> wrap the entire example in dontrun, but then that loses the useful
> checking I get locally when running r cmd check.

You could also not run the example on Windows by wrapping it in 
if(.Platform$OS.type != "windows) {}
but I don't see that as necessary.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Cross-platform check for internet connection
Prof Brian Ripley